Example usage for org.apache.commons.lang StringUtils defaultString

List of usage examples for org.apache.commons.lang StringUtils defaultString

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils defaultString.

Prototype

public static String defaultString(String str, String defaultStr) 

Source Link

Document

Returns either the passed in String, or if the String is null, the value of defaultStr.

Usage

From source file:hudson.plugins.clearcase.AbstractClearCaseScm.java

public String getViewPath() {
    return StringUtils.defaultString(viewPath, viewName);
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelBackup.java

/**
 * Create the panel.// w  ww.java2s. c om
 */
public Hl7ConnectionPanelBackup(Controller theController) {
    myController = theController;

    setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 150, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    setLayout(gridBagLayout);

    mySinglePortRadio = new JRadioButton("Single Port MLLP");
    mySinglePortRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updatePortsModel();
            updatePortsUi();
        }
    });
    myPortButtonGroup.add(mySinglePortRadio);
    GridBagConstraints gbc_SinglePortRadio = new GridBagConstraints();
    gbc_SinglePortRadio.anchor = GridBagConstraints.WEST;
    gbc_SinglePortRadio.insets = new Insets(0, 0, 5, 5);
    gbc_SinglePortRadio.gridx = 0;
    gbc_SinglePortRadio.gridy = 0;
    add(mySinglePortRadio, gbc_SinglePortRadio);

    JPanel panel_4 = new JPanel();
    panel_4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel_4 = new GridBagConstraints();
    gbc_panel_4.fill = GridBagConstraints.BOTH;
    gbc_panel_4.insets = new Insets(0, 0, 5, 0);
    gbc_panel_4.gridx = 1;
    gbc_panel_4.gridy = 0;
    add(panel_4, gbc_panel_4);
    GridBagLayout gbl_panel_4 = new GridBagLayout();
    gbl_panel_4.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel_4.rowHeights = new int[] { 0, 0 };
    gbl_panel_4.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_panel_4.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    panel_4.setLayout(gbl_panel_4);

    mySinglePortTextBox = new JTextField();
    mySinglePortTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            String text = mySinglePortTextBox.getText();
            text = text.replaceAll("[^0-9]+", "");
            if (!StringUtils.equals(mySinglePortTextBox.getText(), text)) {
                final String newVal = text;
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        mySinglePortTextBox.setText(newVal);
                    }
                });
            }
            if (mySinglePortRadio.isSelected()) {
                if (text.length() > 0) {
                    myConnection.setIncomingOrSinglePort(Integer.parseInt(text));
                } else {
                    myConnection.setIncomingOrSinglePort(-1);
                }
            }
        }
    });

    mylabel = new JLabel("Port");
    mylabel.setHorizontalAlignment(SwingConstants.CENTER);
    mylabel.setPreferredSize(new Dimension(60, 16));
    mylabel.setMinimumSize(new Dimension(60, 16));
    mylabel.setMaximumSize(new Dimension(60, 16));
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.insets = new Insets(0, 0, 0, 5);
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    panel_4.add(mylabel, gbc_label);
    GridBagConstraints gbc_SinglePortTextBox = new GridBagConstraints();
    gbc_SinglePortTextBox.insets = new Insets(0, 5, 0, 0);
    gbc_SinglePortTextBox.anchor = GridBagConstraints.WEST;
    gbc_SinglePortTextBox.gridx = 1;
    gbc_SinglePortTextBox.gridy = 0;
    panel_4.add(mySinglePortTextBox, gbc_SinglePortTextBox);
    mySinglePortTextBox.setMinimumSize(new Dimension(100, 28));
    mySinglePortTextBox.setMaximumSize(new Dimension(100, 2147483647));
    mySinglePortTextBox.setColumns(10);

    myDualPortRadio = new JRadioButton("Dual Port MLLP");
    myDualPortRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updatePortsModel();
            updatePortsUi();
        }
    });
    myPortButtonGroup.add(myDualPortRadio);
    GridBagConstraints gbc_DualPortRadio = new GridBagConstraints();
    gbc_DualPortRadio.anchor = GridBagConstraints.WEST;
    gbc_DualPortRadio.insets = new Insets(0, 0, 5, 5);
    gbc_DualPortRadio.gridx = 0;
    gbc_DualPortRadio.gridy = 1;
    add(myDualPortRadio, gbc_DualPortRadio);

    JPanel panel = new JPanel();
    panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_BottomPanel = new GridBagConstraints();
    gbc_BottomPanel.insets = new Insets(0, 0, 5, 0);
    gbc_BottomPanel.fill = GridBagConstraints.BOTH;
    gbc_BottomPanel.gridx = 1;
    gbc_BottomPanel.gridy = 1;
    add(panel, gbc_BottomPanel);
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 };
    gbl_panel.rowHeights = new int[] { 0, 0 };
    gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    panel.setLayout(gbl_panel);

    JLabel lblInbound = new JLabel("Inbound");
    lblInbound.setHorizontalAlignment(SwingConstants.CENTER);
    lblInbound.setPreferredSize(new Dimension(60, 16));
    lblInbound.setMinimumSize(new Dimension(60, 16));
    lblInbound.setMaximumSize(new Dimension(60, 16));
    GridBagConstraints gbc_lblInbound = new GridBagConstraints();
    gbc_lblInbound.insets = new Insets(0, 5, 0, 5);
    gbc_lblInbound.anchor = GridBagConstraints.EAST;
    gbc_lblInbound.gridx = 0;
    gbc_lblInbound.gridy = 0;
    panel.add(lblInbound, gbc_lblInbound);

    myDualIncomingTextBox = new JTextField();
    myDualIncomingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            String text = myDualIncomingTextBox.getText();
            text = text.replaceAll("[^0-9]+", "");
            if (!StringUtils.equals(myDualIncomingTextBox.getText(), text)) {
                final String newVal = text;
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        myDualIncomingTextBox.setText(newVal);
                    }
                });
            }
            if (myDualPortRadio.isSelected()) {
                if (text.length() > 0) {
                    myConnection.setIncomingOrSinglePort(Integer.parseInt(text));
                } else {
                    myConnection.setIncomingOrSinglePort(-1);
                }
            }
        }
    });
    myDualIncomingTextBox.setMaximumSize(new Dimension(100, 2147483647));
    myDualIncomingTextBox.setMinimumSize(new Dimension(100, 28));
    GridBagConstraints gbc_DualIncomingTextBox = new GridBagConstraints();
    gbc_DualIncomingTextBox.anchor = GridBagConstraints.WEST;
    gbc_DualIncomingTextBox.insets = new Insets(0, 0, 0, 5);
    gbc_DualIncomingTextBox.gridx = 1;
    gbc_DualIncomingTextBox.gridy = 0;
    panel.add(myDualIncomingTextBox, gbc_DualIncomingTextBox);
    myDualIncomingTextBox.setColumns(10);

    JLabel lblOutbound = new JLabel("Outbound");
    GridBagConstraints gbc_lblOutbound = new GridBagConstraints();
    gbc_lblOutbound.anchor = GridBagConstraints.EAST;
    gbc_lblOutbound.insets = new Insets(0, 0, 0, 5);
    gbc_lblOutbound.gridx = 2;
    gbc_lblOutbound.gridy = 0;
    panel.add(lblOutbound, gbc_lblOutbound);

    myDualOutgoingTextBox = new JTextField();
    myDualOutgoingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            String text = myDualOutgoingTextBox.getText();
            text = text.replaceAll("[^0-9]+", "");
            if (!StringUtils.equals(myDualOutgoingTextBox.getText(), text)) {
                final String newVal = text;
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        myDualOutgoingTextBox.setText(newVal);
                    }
                });
            }
            if (myDualPortRadio.isSelected()) {
                if (text.length() > 0) {
                    myConnection.setOutgoingPort(Integer.parseInt(text));
                } else {
                    myConnection.setOutgoingPort(-1);
                }
            }
        }
    });
    myDualOutgoingTextBox.setMinimumSize(new Dimension(100, 28));
    myDualOutgoingTextBox.setMaximumSize(new Dimension(100, 2147483647));
    GridBagConstraints gbc_DualOutgoingTextBox = new GridBagConstraints();
    gbc_DualOutgoingTextBox.insets = new Insets(0, 0, 0, 5);
    gbc_DualOutgoingTextBox.anchor = GridBagConstraints.WEST;
    gbc_DualOutgoingTextBox.gridx = 3;
    gbc_DualOutgoingTextBox.gridy = 0;
    panel.add(myDualOutgoingTextBox, gbc_DualOutgoingTextBox);
    myDualOutgoingTextBox.setColumns(10);

    myHl7OverHttpRadioButton = new JRadioButton("HL7 over HTTP");
    myHl7OverHttpRadioButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updatePortsModel();
            updatePortsUi();
        }
    });
    myPortButtonGroup.add(myHl7OverHttpRadioButton);
    GridBagConstraints gbc_Hl7OverHttpRadioButton = new GridBagConstraints();
    gbc_Hl7OverHttpRadioButton.anchor = GridBagConstraints.WEST;
    gbc_Hl7OverHttpRadioButton.insets = new Insets(0, 0, 5, 5);
    gbc_Hl7OverHttpRadioButton.gridx = 0;
    gbc_Hl7OverHttpRadioButton.gridy = 2;
    add(myHl7OverHttpRadioButton, gbc_Hl7OverHttpRadioButton);

    mypanel = new JPanel();
    mypanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.insets = new Insets(0, 0, 5, 0);
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 1;
    gbc_panel.gridy = 2;
    add(mypanel, gbc_panel);
    GridBagLayout gbl_panel2 = new GridBagLayout();
    gbl_panel2.columnWidths = new int[] { 0, 0 };
    gbl_panel2.rowHeights = new int[] { 0, 0 };
    gbl_panel2.columnWeights = new double[] { 0.0, 1.0 };
    gbl_panel2.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    mypanel.setLayout(gbl_panel2);

    mylabel_1 = new JLabel("URL");
    mylabel_1.setHorizontalAlignment(SwingConstants.CENTER);
    mylabel_1.setPreferredSize(new Dimension(60, 16));
    mylabel_1.setMinimumSize(new Dimension(60, 16));
    mylabel_1.setMaximumSize(new Dimension(60, 16));
    GridBagConstraints gbc_label_1 = new GridBagConstraints();
    gbc_label_1.anchor = GridBagConstraints.EAST;
    gbc_label_1.insets = new Insets(0, 0, 0, 5);
    gbc_label_1.gridx = 0;
    gbc_label_1.gridy = 0;
    mypanel.add(mylabel_1, gbc_label_1);

    myHoHUrlTextField = new JTextField();
    myHoHUrlTextField.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            if (myHohUrlTextFieldUpdating) {
                return;
            }

            String value = myHoHUrlTextField.getText();
            try {
                URL url = new URL(value);
                boolean tls;
                if (url.getProtocol().equals("http")) {
                    tls = false;
                } else if (url.getProtocol().equals("https")) {
                    tls = true;
                } else {
                    ourLog.info("Unknown protocol: {}", url.getProtocol());
                    myHoHUrlTextField.setBackground(ERROR_BG);
                    return;
                }

                myConnection.setTls(tls);
                myConnection.setHost(url.getHost());
                myConnection
                        .setIncomingOrSinglePort(url.getPort() != -1 ? url.getPort() : url.getDefaultPort());
                myConnection.setHttpUriPath(url.getPath());

                myHohUrlTextFieldUpdating = true;
                updatePortsUi();
                myHohUrlTextFieldUpdating = false;

                myTlsCheckbox.setSelected(tls);
                myHohTlsCheckbox.setSelected(tls);

                myHoHUrlTextField.setBackground(Color.white);
            } catch (MalformedURLException e) {
                myHoHUrlTextField.setBackground(ERROR_BG);
            }

        }
    });
    GridBagConstraints gbc_HohUsernameTextbox = new GridBagConstraints();
    gbc_HohUsernameTextbox.fill = GridBagConstraints.HORIZONTAL;
    gbc_HohUsernameTextbox.gridx = 1;
    gbc_HohUsernameTextbox.gridy = 0;
    mypanel.add(myHoHUrlTextField, gbc_HohUsernameTextbox);
    myHoHUrlTextField.setColumns(10);

    JLabel lblEncoding = new JLabel("Encoding");
    GridBagConstraints gbc_lblEncoding = new GridBagConstraints();
    gbc_lblEncoding.insets = new Insets(0, 0, 5, 5);
    gbc_lblEncoding.gridx = 0;
    gbc_lblEncoding.gridy = 3;
    add(lblEncoding, gbc_lblEncoding);

    JPanel encodingPanel = new JPanel();
    GridBagConstraints gbc_encodingPanel = new GridBagConstraints();
    gbc_encodingPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_encodingPanel.insets = new Insets(0, 0, 5, 0);
    gbc_encodingPanel.gridx = 1;
    gbc_encodingPanel.gridy = 3;
    add(encodingPanel, gbc_encodingPanel);
    encodingPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagLayout gbl_encodingPanel = new GridBagLayout();
    gbl_encodingPanel.columnWidths = new int[] { 144, 58, 0 };
    gbl_encodingPanel.rowHeights = new int[] { 23, 0 };
    gbl_encodingPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    gbl_encodingPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    encodingPanel.setLayout(gbl_encodingPanel);

    myXmlRadio = new JRadioButton("XML");
    myXmlRadio.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent theE) {
            updateEncodingModel();
        }
    });

    myEr7Radio = new JRadioButton("ER7 (Pipe and hat)");
    myEr7Radio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateEncodingModel();
        }
    });
    encodingButtonGroup.add(myEr7Radio);
    GridBagConstraints gbc_Er7Radio = new GridBagConstraints();
    gbc_Er7Radio.anchor = GridBagConstraints.NORTHWEST;
    gbc_Er7Radio.insets = new Insets(0, 0, 0, 5);
    gbc_Er7Radio.gridx = 0;
    gbc_Er7Radio.gridy = 0;
    encodingPanel.add(myEr7Radio, gbc_Er7Radio);
    encodingButtonGroup.add(myXmlRadio);
    GridBagConstraints gbc_XmlRadio = new GridBagConstraints();
    gbc_XmlRadio.anchor = GridBagConstraints.NORTHWEST;
    gbc_XmlRadio.gridx = 1;
    gbc_XmlRadio.gridy = 0;
    encodingPanel.add(myXmlRadio, gbc_XmlRadio);

    JLabel lblCharset = new JLabel("Charset");
    GridBagConstraints gbc_lblCharset = new GridBagConstraints();
    gbc_lblCharset.insets = new Insets(0, 0, 5, 5);
    gbc_lblCharset.gridx = 0;
    gbc_lblCharset.gridy = 4;
    add(lblCharset, gbc_lblCharset);

    JPanel panel_2 = new JPanel();
    GridBagConstraints gbc_panel_2 = new GridBagConstraints();
    gbc_panel_2.fill = GridBagConstraints.HORIZONTAL;
    gbc_panel_2.insets = new Insets(0, 0, 5, 0);
    gbc_panel_2.gridx = 1;
    gbc_panel_2.gridy = 4;
    add(panel_2, gbc_panel_2);
    panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagLayout gbl_panel_2 = new GridBagLayout();
    gbl_panel_2.columnWidths = new int[] { 28, 198, 0, 0 };
    gbl_panel_2.rowHeights = new int[] { 27, 0 };
    gbl_panel_2.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_panel_2.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    panel_2.setLayout(gbl_panel_2);

    myCharsetSelectRadio = new JRadioButton("");
    myCharsetSelectRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCharsetModel();
        }
    });
    charsetButtonGroup.add(myCharsetSelectRadio);
    GridBagConstraints gbc_CharsetSelectRadio = new GridBagConstraints();
    gbc_CharsetSelectRadio.anchor = GridBagConstraints.WEST;
    gbc_CharsetSelectRadio.insets = new Insets(0, 0, 0, 5);
    gbc_CharsetSelectRadio.gridx = 0;
    gbc_CharsetSelectRadio.gridy = 0;
    panel_2.add(myCharsetSelectRadio, gbc_CharsetSelectRadio);

    myCharsetCombo = new JComboBox();
    myCharsetCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCharsetModel();
        }
    });
    GridBagConstraints gbc_CharsetCombo = new GridBagConstraints();
    gbc_CharsetCombo.anchor = GridBagConstraints.NORTHWEST;
    gbc_CharsetCombo.insets = new Insets(0, 0, 0, 5);
    gbc_CharsetCombo.gridx = 1;
    gbc_CharsetCombo.gridy = 0;
    panel_2.add(myCharsetCombo, gbc_CharsetCombo);

    myCharsetDetectRadio = new JRadioButton("Detect in Message (MSH-18)");
    myCharsetDetectRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCharsetModel();
        }
    });
    charsetButtonGroup.add(myCharsetDetectRadio);
    GridBagConstraints gbc_CharsetDetectRadio = new GridBagConstraints();
    gbc_CharsetDetectRadio.anchor = GridBagConstraints.NORTH;
    gbc_CharsetDetectRadio.gridwidth = 2;
    gbc_CharsetDetectRadio.gridx = 2;
    gbc_CharsetDetectRadio.gridy = 0;
    panel_2.add(myCharsetDetectRadio, gbc_CharsetDetectRadio);

    mylabel_5 = new JLabel("Debug");
    GridBagConstraints gbc_label_5 = new GridBagConstraints();
    gbc_label_5.insets = new Insets(0, 0, 5, 5);
    gbc_label_5.gridx = 0;
    gbc_label_5.gridy = 5;
    add(mylabel_5, gbc_label_5);

    mypanel_2 = new JPanel();
    mypanel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel_75 = new GridBagConstraints();
    gbc_panel_75.insets = new Insets(0, 0, 5, 0);
    gbc_panel_75.fill = GridBagConstraints.BOTH;
    gbc_panel_75.gridx = 1;
    gbc_panel_75.gridy = 5;
    add(mypanel_2, gbc_panel_75);
    GridBagLayout gbl_panel_74 = new GridBagLayout();
    gbl_panel_74.columnWidths = new int[] { 0, 0 };
    gbl_panel_74.rowHeights = new int[] { 0, 0 };
    gbl_panel_74.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_panel_74.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    mypanel_2.setLayout(gbl_panel_74);

    myCaptureByteStreamCheckbox = new JCheckBox("Capture Bytes");
    GridBagConstraints gbc_CaptureByteStreamCheckbox = new GridBagConstraints();
    gbc_CaptureByteStreamCheckbox.gridx = 0;
    gbc_CaptureByteStreamCheckbox.gridy = 0;
    mypanel_2.add(myCaptureByteStreamCheckbox, gbc_CaptureByteStreamCheckbox);
    myCaptureByteStreamCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.setCaptureBytes(myCaptureByteStreamCheckbox.isSelected());
        }
    });
    myCaptureByteStreamCheckbox.setToolTipText("Check this box to capture the transport level communication");

    myInterfaceTypeCardPanel = new JPanel();
    myInterfaceTypeCardPanel.setBorder(null);
    GridBagConstraints gbc_InterfaceTypeCardPanel = new GridBagConstraints();
    gbc_InterfaceTypeCardPanel.gridwidth = 2;
    gbc_InterfaceTypeCardPanel.fill = GridBagConstraints.BOTH;
    gbc_InterfaceTypeCardPanel.gridx = 0;
    gbc_InterfaceTypeCardPanel.gridy = 6;
    add(myInterfaceTypeCardPanel, gbc_InterfaceTypeCardPanel);
    myInterfaceTypeCardPanel.setLayout(new CardLayout(0, 0));

    myMllpCard = new JPanel();
    myMllpCard.setBorder(null);
    myInterfaceTypeCardPanel.add(myMllpCard, IFACE_TYPE_CARD_MLLP);
    GridBagLayout gbl_MllpCard = new GridBagLayout();
    gbl_MllpCard.columnWidths = new int[] { 150, 0, 0 };
    gbl_MllpCard.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_MllpCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_MllpCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    myMllpCard.setLayout(gbl_MllpCard);

    JLabel lblHost = new JLabel("Host");
    GridBagConstraints gbc_lblHost = new GridBagConstraints();
    gbc_lblHost.insets = new Insets(0, 0, 5, 5);
    gbc_lblHost.gridx = 0;
    gbc_lblHost.gridy = 0;
    myMllpCard.add(lblHost, gbc_lblHost);

    mypanel_1 = new JPanel();
    mypanel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.insets = new Insets(0, 0, 5, 0);
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.gridx = 1;
    gbc_panel_1.gridy = 0;
    myMllpCard.add(mypanel_1, gbc_panel_1);
    GridBagLayout gbl_panel_1 = new GridBagLayout();
    gbl_panel_1.columnWidths = new int[] { 134, 0 };
    gbl_panel_1.rowHeights = new int[] { 28, 0 };
    gbl_panel_1.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_1.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    mypanel_1.setLayout(gbl_panel_1);

    myHostBox = new JTextField();
    GridBagConstraints gbc_HostBox = new GridBagConstraints();
    gbc_HostBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_HostBox.anchor = GridBagConstraints.NORTH;
    gbc_HostBox.gridx = 0;
    gbc_HostBox.gridy = 0;
    mypanel_1.add(myHostBox, gbc_HostBox);
    myHostBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myConnection.setHost(myHostBox.getText());
        }
    });
    myHostBox.setColumns(10);

    JLabel lblTransport = new JLabel("Transport");
    GridBagConstraints gbc_lblTransport = new GridBagConstraints();
    gbc_lblTransport.insets = new Insets(0, 0, 5, 5);
    gbc_lblTransport.gridx = 0;
    gbc_lblTransport.gridy = 1;
    myMllpCard.add(lblTransport, gbc_lblTransport);

    JPanel panel_3 = new JPanel();
    GridBagConstraints gbc_hohAuthPanel = new GridBagConstraints();
    gbc_hohAuthPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_hohAuthPanel.insets = new Insets(0, 0, 5, 0);
    gbc_hohAuthPanel.gridx = 1;
    gbc_hohAuthPanel.gridy = 1;
    myMllpCard.add(panel_3, gbc_hohAuthPanel);
    panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagLayout gbl_hohAuthPanel = new GridBagLayout();
    gbl_hohAuthPanel.columnWidths = new int[] { 0, 0, 0 };
    gbl_hohAuthPanel.rowHeights = new int[] { 0, 0 };
    gbl_hohAuthPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    gbl_hohAuthPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    panel_3.setLayout(gbl_hohAuthPanel);

    myTlsCheckbox = new JCheckBox("Use TLS/SSL");
    myTlsCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myHohTlsCheckbox.setSelected(myTlsCheckbox.isSelected());
            myConnection.setTls(myTlsCheckbox.isSelected());
        }
    });
    GridBagConstraints gbc_TlsCheckbox = new GridBagConstraints();
    gbc_TlsCheckbox.insets = new Insets(0, 0, 0, 5);
    gbc_TlsCheckbox.anchor = GridBagConstraints.WEST;
    gbc_TlsCheckbox.gridx = 0;
    gbc_TlsCheckbox.gridy = 0;
    panel_3.add(myTlsCheckbox, gbc_TlsCheckbox);

    myHoHCard = new JPanel();
    myInterfaceTypeCardPanel.add(myHoHCard, IFACE_TYPE_CARD_HOH);
    GridBagLayout gbl_HoHCard = new GridBagLayout();
    gbl_HoHCard.columnWidths = new int[] { 150, 0, 0 };
    gbl_HoHCard.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_HoHCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_HoHCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    myHoHCard.setLayout(gbl_HoHCard);

    mylabel_6 = new JLabel("Authorization");
    GridBagConstraints gbc_label_6 = new GridBagConstraints();
    gbc_label_6.insets = new Insets(0, 0, 5, 5);
    gbc_label_6.gridx = 0;
    gbc_label_6.gridy = 0;
    myHoHCard.add(mylabel_6, gbc_label_6);

    hohAuthPanel = new JPanel();
    hohAuthPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_hohAuthPanel2 = new GridBagConstraints();
    gbc_hohAuthPanel2.insets = new Insets(0, 0, 5, 0);
    gbc_hohAuthPanel2.fill = GridBagConstraints.BOTH;
    gbc_hohAuthPanel2.gridx = 1;
    gbc_hohAuthPanel2.gridy = 0;
    myHoHCard.add(hohAuthPanel, gbc_hohAuthPanel2);
    GridBagLayout gbl_hohAuthPanel3 = new GridBagLayout();
    gbl_hohAuthPanel3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0 };
    gbl_hohAuthPanel3.rowHeights = new int[] { 0, 0 };
    gbl_hohAuthPanel3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    gbl_hohAuthPanel3.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    hohAuthPanel.setLayout(gbl_hohAuthPanel3);

    myHohAuthEnabledCheckbox = new JCheckBox("Enabled");
    myHohAuthEnabledCheckbox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent theE) {
            myConnection.setHohAuthenticationEnabled(myHohAuthEnabledCheckbox.isSelected());
        }
    });
    GridBagConstraints gbc_HohAuthEnabledCheckbox = new GridBagConstraints();
    gbc_HohAuthEnabledCheckbox.insets = new Insets(0, 0, 0, 5);
    gbc_HohAuthEnabledCheckbox.gridx = 0;
    gbc_HohAuthEnabledCheckbox.gridy = 0;
    hohAuthPanel.add(myHohAuthEnabledCheckbox, gbc_HohAuthEnabledCheckbox);

    mylabel_7 = new JLabel("Username:");
    GridBagConstraints gbc_label_7 = new GridBagConstraints();
    gbc_label_7.insets = new Insets(0, 0, 0, 5);
    gbc_label_7.anchor = GridBagConstraints.EAST;
    gbc_label_7.gridx = 1;
    gbc_label_7.gridy = 0;
    hohAuthPanel.add(mylabel_7, gbc_label_7);

    myHohAuthUsernameTextbox = new JTextField();
    myHohAuthUsernameTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myConnection.setHohAuthenticationUsername(myHohAuthUsernameTextbox.getText());
        }
    });
    myHohAuthUsernameTextbox.setMaximumSize(new Dimension(200, 2147483647));
    myHohAuthUsernameTextbox.setMinimumSize(new Dimension(100, 28));
    myHohAuthUsernameTextbox.setPreferredSize(new Dimension(100, 28));
    GridBagConstraints gbc_HohUsernameTextbox2 = new GridBagConstraints();
    gbc_HohUsernameTextbox2.insets = new Insets(0, 0, 0, 5);
    gbc_HohUsernameTextbox2.fill = GridBagConstraints.HORIZONTAL;
    gbc_HohUsernameTextbox2.gridx = 2;
    gbc_HohUsernameTextbox2.gridy = 0;
    hohAuthPanel.add(myHohAuthUsernameTextbox, gbc_HohUsernameTextbox2);
    myHohAuthUsernameTextbox.setColumns(10);

    mylabel_8 = new JLabel("Password:");
    GridBagConstraints gbc_label_8 = new GridBagConstraints();
    gbc_label_8.insets = new Insets(0, 0, 0, 5);
    gbc_label_8.anchor = GridBagConstraints.EAST;
    gbc_label_8.gridx = 3;
    gbc_label_8.gridy = 0;
    hohAuthPanel.add(mylabel_8, gbc_label_8);

    myHohAuthPasswordTextbox = new JTextField();
    myHohAuthPasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myConnection.setHohAuthenticationPassword(myHohAuthPasswordTextbox.getText());
        }
    });
    myHohAuthPasswordTextbox.setPreferredSize(new Dimension(100, 28));
    myHohAuthPasswordTextbox.setMaximumSize(new Dimension(200, 2147483647));
    myHohAuthPasswordTextbox.setMinimumSize(new Dimension(100, 28));
    GridBagConstraints gbc_textField = new GridBagConstraints();
    gbc_textField.insets = new Insets(0, 0, 0, 5);
    gbc_textField.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField.gridx = 4;
    gbc_textField.gridy = 0;
    hohAuthPanel.add(myHohAuthPasswordTextbox, gbc_textField);
    myHohAuthPasswordTextbox.setColumns(10);

    mylabel_2 = new JLabel("Security Profile");
    GridBagConstraints gbc_label_2 = new GridBagConstraints();
    gbc_label_2.insets = new Insets(0, 0, 5, 5);
    gbc_label_2.gridx = 0;
    gbc_label_2.gridy = 1;
    myHoHCard.add(mylabel_2, gbc_label_2);

    securityProfilePanel = new JPanel();
    GridBagConstraints gbc_securityProfilePanel = new GridBagConstraints();
    gbc_securityProfilePanel.insets = new Insets(0, 0, 5, 0);
    gbc_securityProfilePanel.fill = GridBagConstraints.BOTH;
    gbc_securityProfilePanel.gridx = 1;
    gbc_securityProfilePanel.gridy = 1;
    myHoHCard.add(securityProfilePanel, gbc_securityProfilePanel);
    securityProfilePanel.setLayout(new BorderLayout(0, 0));

    myHohTlsCheckbox = new JCheckBox("TLS Enabled");
    myHohTlsCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.setTls(myHohTlsCheckbox.isSelected());
            myTlsCheckbox.setSelected(myHohTlsCheckbox.isSelected());
            updatePortsUi();
        }
    });
    securityProfilePanel.add(myHohTlsCheckbox, BorderLayout.WEST);

    tlsKeystorePanel = new JPanel();
    tlsKeystorePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    securityProfilePanel.add(tlsKeystorePanel, BorderLayout.CENTER);
    GridBagLayout gbl_tlsKeystorePanel = new GridBagLayout();
    gbl_tlsKeystorePanel.columnWidths = new int[] { 58, 107, 77, 0, 0 };
    gbl_tlsKeystorePanel.rowHeights = new int[] { 28, 16, 0 };
    gbl_tlsKeystorePanel.columnWeights = new double[] { 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_tlsKeystorePanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    tlsKeystorePanel.setLayout(gbl_tlsKeystorePanel);

    mylabel_3 = new JLabel("Keystore:");
    GridBagConstraints gbc_label_3 = new GridBagConstraints();
    gbc_label_3.anchor = GridBagConstraints.WEST;
    gbc_label_3.fill = GridBagConstraints.VERTICAL;
    gbc_label_3.insets = new Insets(0, 0, 5, 5);
    gbc_label_3.gridx = 0;
    gbc_label_3.gridy = 0;
    tlsKeystorePanel.add(mylabel_3, gbc_label_3);

    myHohSecurityKeystoreTextbox = new JTextField();
    GridBagConstraints gbc_HohKeystoreTextbox = new GridBagConstraints();
    gbc_HohKeystoreTextbox.gridwidth = 2;
    gbc_HohKeystoreTextbox.anchor = GridBagConstraints.NORTH;
    gbc_HohKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL;
    gbc_HohKeystoreTextbox.insets = new Insets(0, 0, 5, 5);
    gbc_HohKeystoreTextbox.gridx = 1;
    gbc_HohKeystoreTextbox.gridy = 0;
    tlsKeystorePanel.add(myHohSecurityKeystoreTextbox, gbc_HohKeystoreTextbox);
    myHohSecurityKeystoreTextbox.setColumns(10);
    myHohSecurityKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            String text = myHohSecurityKeystoreTextbox.getText();
            myHohSecurityKeyPwTextBox.setEnabled(isNotBlank(text));
            myConnection.setTlsKeystoreLocation(text);
            scheduleHohSecurityKeystoreCheck();
        }
    });

    myHohSecurityKeystoreChooseBtn = new JButton("Choose");
    myHohSecurityKeystoreChooseBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory();
            directory = StringUtils.defaultString(directory, ".");
            JFileChooser chooser = new JFileChooser(directory);
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setDialogTitle("Select a Java Keystore");
            int result = chooser.showOpenDialog(Hl7ConnectionPanelBackup.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                Prefs.getInstance()
                        .setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent());
                myHohSecurityKeystoreTextbox.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    myHohSecurityKeystoreChooseBtn.setIcon(new ImageIcon(
            Hl7ConnectionPanelBackup.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
    GridBagConstraints gbc_button = new GridBagConstraints();
    gbc_button.insets = new Insets(0, 0, 5, 0);
    gbc_button.gridx = 3;
    gbc_button.gridy = 0;
    tlsKeystorePanel.add(myHohSecurityKeystoreChooseBtn, gbc_button);

    mylabel_4 = new JLabel("Store Pass:");
    GridBagConstraints gbc_label_4 = new GridBagConstraints();
    gbc_label_4.insets = new Insets(0, 0, 0, 5);
    gbc_label_4.anchor = GridBagConstraints.EAST;
    gbc_label_4.gridx = 0;
    gbc_label_4.gridy = 1;
    tlsKeystorePanel.add(mylabel_4, gbc_label_4);

    myHohSecurityKeyPwTextBox = new JTextField();
    myHohSecurityKeyPwTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myConnection.setTlsKeystorePassword(myHohSecurityKeyPwTextBox.getText());
            scheduleHohSecurityKeystoreCheck();
        }
    });
    GridBagConstraints gbc_HohSecurityKeyPwTextBox = new GridBagConstraints();
    gbc_HohSecurityKeyPwTextBox.insets = new Insets(0, 0, 0, 5);
    gbc_HohSecurityKeyPwTextBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_HohSecurityKeyPwTextBox.gridx = 1;
    gbc_HohSecurityKeyPwTextBox.gridy = 1;
    tlsKeystorePanel.add(myHohSecurityKeyPwTextBox, gbc_HohSecurityKeyPwTextBox);
    myHohSecurityKeyPwTextBox.setColumns(10);

    myHohSecurityProfileKeystoreStatus = new JLabel("Value goes here");
    myHohSecurityProfileKeystoreStatus.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_HohSecurityProfileKeystoreStatus = new GridBagConstraints();
    gbc_HohSecurityProfileKeystoreStatus.anchor = GridBagConstraints.NORTH;
    gbc_HohSecurityProfileKeystoreStatus.fill = GridBagConstraints.HORIZONTAL;
    gbc_HohSecurityProfileKeystoreStatus.gridwidth = 2;
    gbc_HohSecurityProfileKeystoreStatus.gridx = 2;
    gbc_HohSecurityProfileKeystoreStatus.gridy = 1;
    tlsKeystorePanel.add(myHohSecurityProfileKeystoreStatus, gbc_HohSecurityProfileKeystoreStatus);

    init();

}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Internal implementation to add an image (a world map, though other image data is also fine) to a slide.
 *   Preserves the original image's aspect ratio, leaving blank space below and to the sides of the image.
 * @param slide the slide to add to./*w  ww  .  ja  v a  2  s .c o m*/
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param picture the picture data.
 * @param markers an array of markers to draw over the map.
 * @param polygons
 * @return the picture shape object added to the slide.
 */
private static XSLFPictureShape addMap(final XSLFSlide slide, final Rectangle2D.Double anchor,
        final XSLFPictureData picture, final Marker[] markers, final MapData.Polygon[] polygons) {
    double tgtW = anchor.getWidth(), tgtH = anchor.getHeight();

    final Dimension size = picture.getImageDimension();
    final double ratio = size.getWidth() / size.getHeight();

    if (ratio > tgtW / tgtH) {
        // source image is wider than target, clip fixed width variable height
        tgtH = tgtW / ratio;
    } else {
        tgtW = tgtH * ratio;
    }

    final XSLFPictureShape canvas = slide.createPicture(picture);
    // Vertically align top, horizontally-align center
    final double offsetX = anchor.getMinX() + 0.5 * (anchor.getWidth() - tgtW), offsetY = anchor.getMinY();
    canvas.setAnchor(new Rectangle2D.Double(offsetX, offsetY, tgtW, tgtH));

    if (polygons != null) {
        for (MapData.Polygon polygon : polygons) {
            final Color color = Color.decode(polygon.getColor());
            final double[][] shapes = polygon.getPoints();
            // The ESRI spec version 1.2.1 from http://www.opengeospatial.org/standards/sfa has section 6.1.11.1,
            //    which defines polygons as follows:
            /// A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries.
            //    Each interior boundary defines a hole in the Polygon. A Triangle is a polygon with 3 distinct,
            //    non-collinear vertices and no interior boundary.
            /// The exterior boundary LinearRing defines the top? of the surface which is the side of the surface
            //    from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.
            //    The interior LinearRings will have the opposite orientation, and appear as clockwise
            //    when viewed from the top?
            // so it's even-odd winding (whereas the Path2D default is non-zero-winding).
            final Path2D.Double path = new Path2D.Double(Path2D.WIND_EVEN_ODD);

            for (final double[] points : shapes) {
                for (int ii = 0; ii < points.length; ii += 2) {
                    final double x1 = offsetX + points[ii] * tgtW;
                    final double y1 = offsetY + points[ii + 1] * tgtH;
                    if (ii == 0) {
                        path.moveTo(x1, y1);
                    } else {
                        path.lineTo(x1, y1);
                    }
                }
                path.closePath();
            }

            final XSLFFreeformShape freeform = slide.createFreeform();
            freeform.setPath(path);
            freeform.setStrokeStyle(0.5);
            // There's a 0.5 alpha transparency on the stroke, and a 0.2 alpha transparency on the polygon fill.
            freeform.setLineColor(transparentColor(color, 128));
            freeform.setFillColor(transparentColor(color, 51));

            if (StringUtils.isNotEmpty(polygon.getText())) {
                final PackageRelationship rel = freeform.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the polygon
                final CTHyperlink link = ((CTShape) freeform.getXmlObject()).getNvSpPr().getCNvPr()
                        .addNewHlinkClick();
                link.setTooltip(polygon.getText());
                link.setId(rel.getId());
                link.setAction("ppaction://hlinksldjump");
            }
        }
    }

    for (Marker marker : markers) {
        final Color color = Color.decode(marker.getColor());
        final double centerX = offsetX + marker.getX() * tgtW;
        final double centerY = offsetY + marker.getY() * tgtH;

        if (marker.isCluster()) {
            final XSLFGroupShape group = slide.createGroup();
            double halfMark = 10;
            double mark = halfMark * 2;
            double innerHalfMark = 7;
            double innerMark = innerHalfMark * 2;
            // align these so the middle is the latlng position
            final Rectangle2D.Double groupAnchor = new Rectangle2D.Double(centerX - halfMark,
                    centerY - halfMark, mark, mark);

            group.setAnchor(groupAnchor);
            group.setInteriorAnchor(groupAnchor);

            final XSLFAutoShape shape = group.createAutoShape();
            shape.setShapeType(ShapeType.ELLIPSE);
            final boolean fade = marker.isFade();
            // There's a 0.3 alpha transparency (255 * 0.3 is 76) when a marker is faded out
            final int FADE_ALPHA = 76;
            shape.setFillColor(transparentColor(color, fade ? 47 : 154));
            shape.setAnchor(groupAnchor);

            final XSLFAutoShape inner = group.createAutoShape();
            inner.setFillColor(fade ? transparentColor(color, FADE_ALPHA) : color);
            inner.setLineWidth(0.1);
            inner.setLineColor(new Color((int) (color.getRed() * 0.9), (int) (color.getGreen() * 0.9),
                    (int) (color.getBlue() * 0.9), fade ? FADE_ALPHA : 255));
            inner.setShapeType(ShapeType.ELLIPSE);
            inner.setHorizontalCentered(true);
            inner.setWordWrap(false);
            inner.setVerticalAlignment(VerticalAlignment.MIDDLE);
            inner.clearText();
            final XSLFTextParagraph para = inner.addNewTextParagraph();
            para.setTextAlign(TextParagraph.TextAlign.CENTER);
            final XSLFTextRun text = para.addNewTextRun();
            text.setFontSize(6.0);
            final Color fontColor = Color.decode(StringUtils.defaultString(marker.getFontColor(), "#000000"));
            text.setFontColor(fade ? transparentColor(fontColor, FADE_ALPHA) : fontColor);
            text.setText(marker.getText());
            inner.setAnchor(new Rectangle2D.Double(centerX - innerHalfMark, centerY - innerHalfMark, innerMark,
                    innerMark));
        } else {
            final XSLFGroupShape group = slide.createGroup();

            final XSLFFreeformShape shape = group.createFreeform();
            shape.setHorizontalCentered(true);
            shape.setWordWrap(false);

            shape.setVerticalAlignment(VerticalAlignment.BOTTOM);
            shape.setLineWidth(0.5);
            shape.setLineColor(color.darker());
            shape.setFillColor(transparentColor(color, 210));

            final double halfMark = 8, mark = halfMark * 2, extension = 0.85,
                    markerHeight = (0.5 + extension) * mark, angle = Math.asin(0.5 / extension) * 180 / Math.PI;

            // Set group position
            group.setAnchor(
                    new Rectangle2D.Double(centerX - halfMark, centerY - markerHeight, mark, markerHeight));
            group.setInteriorAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            // Draw a semicircle and a triangle to represent the marker, pointing at the precise x,y location
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(halfMark, markerHeight);
            path.append(new Arc2D.Double(0, 0, mark, mark, -angle, 180 + angle + angle, Arc2D.OPEN), true);
            path.lineTo(halfMark, markerHeight);
            shape.setPath(path);
            shape.setAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            final XSLFAutoShape disc = group.createAutoShape();
            disc.setShapeType(ShapeType.DONUT);
            final double discRadius = 0.25 * mark;
            final double discDiameter = 2 * discRadius;
            disc.setAnchor(new Rectangle2D.Double(halfMark - discRadius, halfMark - discRadius, discDiameter,
                    discDiameter));
            disc.setFillColor(Color.WHITE);
            disc.setLineColor(Color.WHITE);

            if (StringUtils.isNotEmpty(marker.getText())) {
                final PackageRelationship rel = shape.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the marker
                // Annoyingly, you can't put a link on the group, just on the individual shapes.
                for (XSLFShape clickable : group.getShapes()) {
                    final CTHyperlink link = ((CTShape) clickable.getXmlObject()).getNvSpPr().getCNvPr()
                            .addNewHlinkClick();
                    link.setTooltip(marker.getText());
                    link.setId(rel.getId());
                    link.setAction("ppaction://hlinksldjump");
                }
            }
        }
    }

    return canvas;
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelBackup.java

private void updatePortsUi() {
    boolean changesAllowed = isChangesAllowed();
    CardLayout cl = (CardLayout) myInterfaceTypeCardPanel.getLayout();

    switch (myConnection.getTransport()) {
    case DUAL_PORT_MLLP: {
        mySinglePortRadio.setSelected(false);
        myDualPortRadio.setSelected(true);
        myHl7OverHttpRadioButton.setSelected(false);

        myDualIncomingTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
        myDualOutgoingTextBox.setText(portToString(myConnection.getOutgoingPort()));

        mySinglePortTextBox.setEnabled(false);
        myDualIncomingTextBox.setEnabled(true && changesAllowed);
        myDualOutgoingTextBox.setEnabled(true && changesAllowed);
        myHoHUrlTextField.setEnabled(false);
        mySinglePortTextBox.repaint();/*from  w w w .  j  a  v  a 2s  . c  o  m*/
        myDualIncomingTextBox.repaint();
        myDualOutgoingTextBox.repaint();

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanelBackup.IFACE_TYPE_CARD_MLLP);
        break;
    }
    case SINGLE_PORT_MLLP: {
        mySinglePortRadio.setSelected(true);
        myDualPortRadio.setSelected(false);
        myHl7OverHttpRadioButton.setSelected(false);

        mySinglePortTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));

        mySinglePortTextBox.setEnabled(true && changesAllowed);
        myDualIncomingTextBox.setEnabled(false);
        myDualOutgoingTextBox.setEnabled(false);
        myHoHUrlTextField.setEnabled(false);
        mySinglePortTextBox.repaint();
        myDualIncomingTextBox.repaint();
        myDualOutgoingTextBox.repaint();

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanelBackup.IFACE_TYPE_CARD_MLLP);
        break;
    }
    case HL7_OVER_HTTP: {
        mySinglePortTextBox.setEnabled(false);
        myDualIncomingTextBox.setEnabled(false);
        myDualOutgoingTextBox.setEnabled(false);
        mySinglePortRadio.setSelected(false);
        myDualPortRadio.setSelected(false);
        myHl7OverHttpRadioButton.setSelected(true);

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanelBackup.IFACE_TYPE_CARD_HOH);

        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append((myConnection.isTls() ? "https://" : "http://"));
        urlBuilder.append(StringUtils.defaultString(myConnection.getHost(), "localhost"));
        urlBuilder.append(":").append(myConnection.getIncomingOrSinglePort());
        urlBuilder.append(StringUtils.defaultString(myConnection.getHttpUriPath(), "/"));
        String url = urlBuilder.toString();
        if (!myHohUrlTextFieldUpdating) {
            myHohUrlTextFieldUpdating = true;
            myHoHUrlTextField.setText(url);
            myHohUrlTextFieldUpdating = false;
        }

        myHoHUrlTextField.setEnabled(true && changesAllowed);

        break;
    }
    }
}

From source file:com.flexive.ejb.beans.AccountEngineBean.java

/**
 * {@inheritDoc}/*from ww  w  . j av  a  2  s  .c  om*/
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void update(long accountId, String password, Long defaultNode, String name, String loginName,
        String email, Boolean isConfirmed, Boolean isActive, Date validFrom, Date validTo, Long lang,
        String description, Boolean allowMultiLogin, Long contactDataId) throws FxApplicationException {

    // Load the account to update
    Account account = load(accountId);

    StringBuilder sbHistory = new StringBuilder(1000);
    sbHistory.append("<original>\n").append("  <id>").append(accountId).append("</id>\n").append("  <mandator>")
            .append(CacheAdmin.getEnvironment().getMandator(account.getMandatorId()).getName())
            .append("</mandator>\n").append("  <username>").append(account.getName()).append("</username>\n")
            .append("  <loginname>").append(account.getLoginName()).append("</loginname>\n").append("  <email>")
            .append(account.getEmail()).append("</email>\n").append("  <validfrom>")
            .append(account.getValidFromString()).append("</validfrom>\n").append("  <validto>")
            .append(account.getValidToString()).append("</validto>\n").append("  <description><![CDATA[")
            .append(account.getDescription()).append("]]></description>\n").append("  <active>")
            .append(account.isActive()).append("</active>\n").append("  <confirmed>")
            .append(account.isValidated()).append("</confirmed>\n").append("  <multilogin>")
            .append(account.isAllowMultiLogin()).append("</multilogin>\n").append("</original>\n");

    final UserTicket ticket = FxContext.getUserTicket();
    // Determine if only fields are accessed that the use may alter for himself
    final boolean protectedFields = (name != null || loginName != null || isConfirmed != null
            || isActive != null || validTo != null || validFrom != null || description != null);
    if (!protectedFields && ticket.getUserId() == accountId) {
        // passed
    } else {
        if (!_checkPermissions(account)[MAY_UPDATE])
            throw new FxNoAccessException(LOG, "ex.account.update.noPermission", account.getName());
    }

    // Parameter checks
    try {
        if (loginName != null)
            loginName = checkLoginName(loginName);
        if (email != null)
            email = FxFormatUtils.checkEmail(email);
        if (password != null) {
            password = FxFormatUtils.encodePassword(accountId,
                    StringUtils.defaultString(loginName, account.getLoginName()), password.trim());
        }
        if (lang != null && !language.isValid(lang))
            throw new FxInvalidParameterException("LANGUAGE", "ex.account.languageInvalid", lang);
    } catch (FxInvalidParameterException pe) {
        if (LOG.isInfoEnabled())
            LOG.info(pe);
        throw pe;
    }

    Connection con = null;
    PreparedStatement stmt = null;
    String curSql;

    if (name == null)
        name = account.getName();
    if (loginName == null)
        loginName = account.getLoginName();
    if (email == null)
        email = account.getEmail();
    if (lang == null)
        lang = account.getLanguage().getId();
    if (isActive == null)
        isActive = account.isActive();
    if (isConfirmed == null)
        isConfirmed = account.isValidated();
    if (description == null)
        description = account.getDescription();
    if (defaultNode == null)
        defaultNode = account.getDefaultNode();
    if (allowMultiLogin == null)
        allowMultiLogin = account.isAllowMultiLogin();
    // Assign and check dates
    if (validFrom == null)
        validFrom = account.getValidFrom();
    if (validTo == null)
        validTo = account.getValidTo();
    checkDates(validFrom, validTo);
    if (defaultNode < 0)
        defaultNode = (long) 0;

    try {

        // Obtain a database connection
        con = Database.getDbConnection();

        curSql = "UPDATE " + TBL_ACCOUNTS + " SET " +
        // 1          2            3            4           5               6
                "EMAIL=?,LANG=?,VALID_FROM=?,VALID_TO=?,DESCRIPTION=?," +
                // 6                  7             8            9              10
                "MODIFIED_BY=?,MODIFIED_AT=?,IS_ACTIVE=?,IS_VALIDATED=?,DEFAULT_NODE=?," +
                //  11,        12     ,    13      ,                                14
                "USERNAME=?,LOGIN_NAME=?,ALLOW_MULTILOGIN=?" + ((password != null) ? ",PASSWORD=?" : "")
                + ((contactDataId != null) ? ",CONTACT_ID=?" : "") + " WHERE ID=" + accountId;
        stmt = con.prepareStatement(curSql);
        stmt.setString(1, email);
        stmt.setInt(2, lang.intValue());
        stmt.setLong(3, validFrom.getTime());
        stmt.setLong(4, validTo.getTime());
        stmt.setString(5, description);
        stmt.setLong(6, ticket.getUserId());
        stmt.setLong(7, System.currentTimeMillis());
        stmt.setBoolean(8, isActive);
        stmt.setBoolean(9, isConfirmed);
        stmt.setLong(10, defaultNode);
        stmt.setString(11, name);
        stmt.setString(12, loginName);
        stmt.setBoolean(13, allowMultiLogin);
        int pos = 14;
        if (password != null)
            stmt.setString(pos++, password);
        if (contactDataId != null)
            stmt.setLong(pos/*++*/, contactDataId);
        stmt.executeUpdate();
        if (contactDataId != null) {
            //make sure the user is the owner of his contact data
            stmt.close();
            stmt = con.prepareStatement("UPDATE " + TBL_CONTENT + " SET CREATED_BY=? WHERE ID=?");
            stmt.setLong(1, accountId);
            stmt.setLong(2, contactDataId);
            stmt.executeUpdate();
        }

        // Log the user out of the system if he was made active
        if (!isActive || !isConfirmed) {
            UserTicketStore.removeUserId(accountId, null);
        } else {
            // Ensure any active ticket of the updated user are refreshed
            UserTicketStore.flagDirtyHavingUserId(account.getId());
        }

        sbHistory.append("<new>\n").append("  <id>").append(accountId).append("</id>\n").append("  <mandator>")
                .append(CacheAdmin.getEnvironment().getMandator(account.getMandatorId()).getName())
                .append("</mandator>\n").append("  <username>").append(name).append("</username>\n")
                .append("  <loginname>").append(loginName).append("</loginname>\n").append("  <email>")
                .append(email).append("</email>\n").append("  <validfrom>")
                .append(FxFormatUtils.toString(validFrom)).append("</validfrom>\n").append("  <validto>")
                .append(FxFormatUtils.toString(validTo)).append("</validto>\n")
                .append("  <description><![CDATA[").append(description).append("]]></description>\n")
                .append("  <active>").append(isActive).append("</active>\n").append("  <confirmed>")
                .append(isConfirmed).append("</confirmed>\n").append("  <multilogin>").append(allowMultiLogin)
                .append("</multilogin>\n").append("</new>");
        EJBLookup.getHistoryTrackerEngine().trackData(sbHistory.toString(), "history.account.update",
                account.getLoginName());
    } catch (SQLException exc) {
        final boolean uniqueConstraintViolation = StorageManager.isUniqueConstraintViolation(exc);
        EJBUtils.rollback(ctx);
        if (uniqueConstraintViolation) {
            throw new FxEntryExistsException(LOG, "ex.account.userExists", name, loginName);
        } else {
            throw new FxUpdateException(LOG, "ex.account.update.failed.sql", account.getLoginName(),
                    exc.getMessage());
        }
    } finally {
        Database.closeObjects(AccountEngineBean.class, con, stmt);
    }
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanel.java

private void updatePortsUi() {
    boolean changesAllowed = isChangesAllowed();
    CardLayout cl = (CardLayout) myInterfaceTypeCardPanel.getLayout();

    switch (myConnection.getTransport()) {
    case DUAL_PORT_MLLP: {
        mySinglePortRadio.setSelected(false);
        myDualPortRadio.setSelected(true);
        myHl7OverHttpRadioButton.setSelected(false);

        myDualIncomingTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
        myDualOutgoingTextBox.setText(portToString(myConnection.getOutgoingPort()));

        mySinglePortTextBox.setEnabled(false);
        myDualIncomingTextBox.setEnabled(true && changesAllowed);
        myDualOutgoingTextBox.setEnabled(true && changesAllowed);
        myHoHUrlTextField.setEnabled(false);
        mySinglePortTextBox.repaint();//from w ww  .  ja v  a  2  s . com
        myDualIncomingTextBox.repaint();
        myDualOutgoingTextBox.repaint();

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
        break;
    }
    case SINGLE_PORT_MLLP: {
        mySinglePortRadio.setSelected(true);
        myDualPortRadio.setSelected(false);
        myHl7OverHttpRadioButton.setSelected(false);

        mySinglePortTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));

        mySinglePortTextBox.setEnabled(true && changesAllowed);
        myDualIncomingTextBox.setEnabled(false);
        myDualOutgoingTextBox.setEnabled(false);
        myHoHUrlTextField.setEnabled(false);
        mySinglePortTextBox.repaint();
        myDualIncomingTextBox.repaint();
        myDualOutgoingTextBox.repaint();

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
        break;
    }
    case HL7_OVER_HTTP: {
        mySinglePortTextBox.setEnabled(false);
        myDualIncomingTextBox.setEnabled(false);
        myDualOutgoingTextBox.setEnabled(false);
        mySinglePortRadio.setSelected(false);
        myDualPortRadio.setSelected(false);
        myHl7OverHttpRadioButton.setSelected(true);

        cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_HOH);

        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append((myConnection.isTls() ? "https://" : "http://"));
        urlBuilder.append(StringUtils.defaultString(myConnection.getHost(), "localhost"));
        urlBuilder.append(":").append(myConnection.getIncomingOrSinglePort());
        urlBuilder.append(StringUtils.defaultString(myConnection.getHttpUriPath(), "/"));
        String url = urlBuilder.toString();
        if (!myHohUrlTextFieldUpdating) {
            myHohUrlTextFieldUpdating = true;
            myHoHUrlTextField.setText(url);
            myHohUrlTextFieldUpdating = false;
        }

        myHoHUrlTextField.setEnabled(true && changesAllowed);

        break;
    }
    }
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanel.java

private static void chooseKeystore(Component theParentController, JTextField theTextbox) {
    String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory();
    directory = StringUtils.defaultString(directory, ".");
    JFileChooser chooser = new JFileChooser(directory);
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setDialogTitle("Select a Java Keystore");
    int result = chooser.showOpenDialog(theParentController);
    if (result == JFileChooser.APPROVE_OPTION) {
        Prefs.getInstance().setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent());
        theTextbox.setText(chooser.getSelectedFile().getAbsolutePath());
    }/*from w  w w.jav  a  2s .co  m*/
}

From source file:fr.paris.lutece.plugins.document.web.DocumentJspBean.java

/**
 * Gets the document creation page//from   w ww.j  a v  a 2s.  co  m
 * @param request The HTTP request
 * @return The document creation page
 */
public IPluginActionResult getMassArchivalDocument(HttpServletRequest request) {
    IPluginActionResult result = new DefaultPluginActionResult();

    if (!RBACService.isAuthorized(new DocumentMassAction(),
            DocumentMassActionResourceService.PERMISSION_MASS_ARCHIVE, getUser())) {
        result.setHtmlContent(getManageDocuments(request));

        return result;
    }

    // Empty previous just in case
    request.getSession().removeAttribute("to_archive");

    String strAction = request.getParameter(DocumentJspBean.PARAMETER_ACTION);
    String strCriteria = request.getParameter(PARAMETER_ARCHIVAL_CRITERIA);
    String strTypeCode = request.getParameter(PARAMETER_DOCUMENT_TYPE_CODE);
    String strDateMin = request.getParameter(PARAMETER_DATE_MIN);
    String strDateMax = request.getParameter(PARAMETER_DATE_MAX);

    if (StringUtils.isBlank(strCriteria)) {
        strCriteria = (String) request.getSession().getAttribute(PARAMETER_ARCHIVAL_CRITERIA);
        request.getSession().removeAttribute(PARAMETER_ARCHIVAL_CRITERIA);
    }

    if (StringUtils.isBlank(strTypeCode)) {
        strTypeCode = (String) request.getSession().getAttribute(PARAMETER_DOCUMENT_TYPE_CODE);
        request.getSession().removeAttribute(PARAMETER_DOCUMENT_TYPE_CODE);
    }

    if (StringUtils.isBlank(strDateMin)) {
        strDateMin = (String) request.getSession().getAttribute(PARAMETER_DATE_MIN);
        request.getSession().removeAttribute(PARAMETER_DATE_MIN);
    }

    if (StringUtils.isBlank(strDateMax)) {
        strDateMax = (String) request.getSession().getAttribute(PARAMETER_DATE_MAX);
        request.getSession().removeAttribute(PARAMETER_DATE_MAX);
    }

    if ("apply".equals(strAction)) {
        DocumentFilter filter = new DocumentFilter();
        filter.setIsPublished(false);

        request.getSession().setAttribute(PARAMETER_ARCHIVAL_CRITERIA, strCriteria);

        if ("date".equals(strCriteria)) {
            if (StringUtils.isBlank(strDateMin) && StringUtils.isBlank(strDateMax)) {
                result.setRedirect(AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS,
                        "jsp/admin/plugins/document/MassArchivalDocument.jsp", AdminMessage.TYPE_ERROR));
            } else {
                try {
                    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                    SimpleDateFormat sqlSdf = new SimpleDateFormat("yyyy-MM-dd");

                    if (StringUtils.isNotBlank(strDateMin)) {
                        Date dateMin;
                        dateMin = sdf.parse(strDateMin);
                        filter.setDateMin(sqlSdf.format(dateMin));
                    }

                    if (StringUtils.isNotBlank(strDateMax)) {
                        Date dateMax = sdf.parse(strDateMax);
                        filter.setDateMax(sqlSdf.format(dateMax));
                    }

                    request.getSession().setAttribute(PARAMETER_DATE_MIN, strDateMin);
                    request.getSession().setAttribute(PARAMETER_DATE_MAX, strDateMax);
                } catch (ParseException e) {
                    AppLogService.error(e);
                }
            }
        } else if ("space".equals(strCriteria)) {
            String strSpaceId = request.getParameter(DocumentSpacesService.PARAMETER_BROWSER_SELECTED_SPACE_ID);

            if (StringUtils.isBlank(strSpaceId) || !StringUtils.isNumeric(strSpaceId)) {
                result.setRedirect(AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS,
                        "jsp/admin/plugins/document/MassArchivalDocument.jsp", AdminMessage.TYPE_ERROR));
            }

            filter.setIdSpace(Integer.valueOf(strSpaceId));
        } else if ("type".equals(strCriteria)) {
            request.getSession().setAttribute(PARAMETER_DOCUMENT_TYPE_CODE, strTypeCode);
            filter.setCodeDocumentType(strTypeCode);
        } else {
            result.setRedirect(AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS,
                    "jsp/admin/plugins/document/MassArchivalDocument.jsp", AdminMessage.TYPE_ERROR));
        }

        if (result.getRedirect() == null) {
            List<Document> documents = DocumentHome.findByFilter(filter, getLocale());
            List<Document> toArchive = new ArrayList<Document>();

            for (Document doc : documents) {
                if (isAuthorized(DocumentAction.ACTION_ARCHIVE, doc)) {
                    toArchive.add(doc);
                }
            }

            if (CollectionUtils.isNotEmpty(toArchive)) {
                request.getSession().setAttribute("to_archive", toArchive);
                result.setRedirect(AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_MASS_ARCHIVE,
                        new String[] { toArchive.size() + "" },
                        "jsp/admin/plugins/document/DoMassArchivalDocument.jsp",
                        AdminMessage.TYPE_CONFIRMATION));
            } else {
                result.setRedirect(AdminMessageService.getMessageUrl(request, MESSAGE_NO_MASS_ARCHIVE,
                        "jsp/admin/plugins/document/MassArchivalDocument.jsp", AdminMessage.TYPE_ERROR));
            }
        }
    } else {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put(MARK_SELECTED_CRITERIA, StringUtils.defaultString(strCriteria, "date"));
        model.put(MARK_LOCALE, getLocale().getLanguage());
        model.put(MARK_SPACES_BROWSER, DocumentSpacesService.getInstance().getSpacesBrowser(request, getUser(),
                getLocale(), false, true));
        model.put(MARK_DOCUMENT_TYPES_LIST, DocumentTypeHome.findAll());
        model.put(MARK_DOCUMENT_TYPE, StringUtils.defaultString(strTypeCode));
        model.put(MARK_DATE_MIN, StringUtils.defaultString(strDateMin));
        model.put(MARK_DATE_MAX, StringUtils.defaultString(strDateMax));

        HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MASS_ARCHIVAL, getLocale(), model);
        result.setHtmlContent(getAdminPage(template.getHtml()));
    }

    return result;
}

From source file:org.ambraproject.action.FeedbackAction.java

/**
 * @return webwork status/*from w  w w.j a v a2 s.c  om*/
 * @throws Exception Exception
 */
public String executeSend() throws Exception {
    if (!validates())
        return INPUT;

    final Map<String, Object> mapFields = new HashMap<String, Object>();
    mapFields.put("page", page);
    mapFields.put("subject", subject);
    mapFields.put("name", name);
    mapFields.put(FROM_EMAIL_ADDRESS_KEY, fromEmailAddress);
    mapFields.put("note", note);
    setUserDetailsFromSession();
    mapFields.put("id", StringUtils.defaultString(userID, "not found"));

    final Map<String, String> attributes = getUserSessionAttributes();
    final List<String> values = new ArrayList<String>();
    for (Map.Entry<String, String> entry : attributes.entrySet()) {
        values.add(entry.getKey() + " ---> " + entry.getValue());
    }

    mapFields.put("userInfo", StringUtils.join(values.iterator(), "<br/>\n"));
    ambraMailer.sendFeedback(fromEmailAddress, mapFields);
    return SUCCESS;
}

From source file:org.apache.archiva.proxy.DefaultRepositoryProxyConnectors.java

/**
 * Apply the policies.//from  ww w  .  j a v a  2  s.c om
 *
 * @param policies  the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
 * @param settings  the map of settings for the policies to execute. (Map of String policy keys, to String policy
 *                  setting)
 * @param request   the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)}
 *                  )
 * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)})
 * @throws PolicyViolationException
 */
private void validatePolicies(Map<String, ? extends DownloadPolicy> policies, Map<String, String> settings,
        Properties request, File localFile) throws PolicyViolationException {
    for (Entry<String, ? extends DownloadPolicy> entry : policies.entrySet()) {
        // olamy with spring rolehint is now downloadPolicy#hint
        // so substring after last # to get the hint as with plexus
        String key = StringUtils.substringAfterLast(entry.getKey(), "#");
        DownloadPolicy policy = entry.getValue();
        String defaultSetting = policy.getDefaultOption();

        String setting = StringUtils.defaultString(settings.get(key), defaultSetting);

        log.debug("Applying [{}] policy with [{}]", key, setting);
        try {
            policy.applyPolicy(setting, request, localFile);
        } catch (PolicyConfigurationException e) {
            log.error(e.getMessage(), e);
        }
    }
}