Search in sources :

Example 1 with AdvancedParams

use of org.weasis.dicom.param.AdvancedParams in project karnak by OsiriX-Foundation.

the class GatewaySetUpService method getDefaultAdvancedParameters.

private static AdvancedParams getDefaultAdvancedParameters() {
    AdvancedParams params = new AdvancedParams();
    ConnectOptions connectOptions = new ConnectOptions();
    connectOptions.setConnectTimeout(5000);
    connectOptions.setAcceptTimeout(7000);
    // Concurrent DICOM operations
    connectOptions.setMaxOpsInvoked(50);
    connectOptions.setMaxOpsPerformed(50);
    params.setConnectOptions(connectOptions);
    return params;
}
Also used : ConnectOptions(org.weasis.dicom.param.ConnectOptions) AdvancedParams(org.weasis.dicom.param.AdvancedParams)

Example 2 with AdvancedParams

use of org.weasis.dicom.param.AdvancedParams in project karnak by OsiriX-Foundation.

the class Util method getEchoResponse.

public static boolean getEchoResponse(StringBuilder result, String callingAET, DicomNode calledNode, boolean fontIcon, String format, Integer connectTimeout) {
    boolean success = false;
    boolean xml = "XML".equalsIgnoreCase(format);
    try {
        AdvancedParams params = new AdvancedParams();
        DicomState state;
        if (connectTimeout != null) {
            ConnectOptions connectOptions = new ConnectOptions();
            connectOptions.setConnectTimeout(connectTimeout);
            params.setConnectOptions(connectOptions);
            state = Echo.process(params, new DicomNode(callingAET), calledNode);
        } else {
            state = Echo.process(callingAET, calledNode);
        }
        success = state.getStatus() == Status.Success;
        if (xml) {
            result.append("<DcmStatus>");
            if (success) {
                result.append("Success").append("</DcmStatus>");
                result.append("<DcmStatusMessage>").append(state.getMessage()).append("</DcmStatusMessage>");
            } else {
                result.append("Error ").append(Integer.toHexString(state.getStatus())).append("</DcmStatus>");
                result.append("<DcmStatusMessage>").append(state.getMessage()).append("</DcmStatusMessage>");
            }
        } else {
            // "HTML" and anything else
            result.append(success ? "<span style=\"color:green\">" + getOKItem(fontIcon) : "<span style=\"color:red\">" + getWarningItem(fontIcon));
            result.append("</span> DICOM Status: ");
            if (success) {
                result.append("Success");
            } else {
                result.append("error code ");
                result.append(Integer.toHexString(state.getStatus()));
            }
            result.append("<br>DICOM Message: ");
            result.append(state.getMessage());
            result.append("<br>");
        }
    } catch (Throwable e) {
        if (xml) {
            result.append("<DcmStatus>DICOM unexpected error</DcmStatus>");
            result.append("<DcmStatusMessage>").append(e.getMessage()).append("</DcmStatusMessage>");
        } else {
            // "HTML" and anything else
            result.append("<span style=\"color:red\">");
            result.append(getWarningItem(fontIcon));
            result.append(" DICOM unexpected error: ");
            result.append(e.getMessage());
            result.append("</span><br>");
        }
    }
    return success;
}
Also used : DicomState(org.weasis.dicom.param.DicomState) ConnectOptions(org.weasis.dicom.param.ConnectOptions) AdvancedParams(org.weasis.dicom.param.AdvancedParams) DicomNode(org.weasis.dicom.param.DicomNode)

Example 3 with AdvancedParams

use of org.weasis.dicom.param.AdvancedParams in project karnak by OsiriX-Foundation.

the class GatewaySetUpService method getAdvancedParams.

public AdvancedParams getAdvancedParams() {
    AdvancedParams options = getDefaultAdvancedParameters();
    ConnectOptions connectOptions = options.getConnectOptions();
    if (getListenerTLS()) {
        TlsOptions tls = new TlsOptions(false, getClientKey(), "JKS", getClientKeyPwd(), getClientKeyPwd(), getTruststore(), "JKS", getTruststorePwd());
        options.setTlsOptions(tls);
    }
    options.setConnectOptions(connectOptions);
    return options;
}
Also used : ConnectOptions(org.weasis.dicom.param.ConnectOptions) AdvancedParams(org.weasis.dicom.param.AdvancedParams) TlsOptions(org.weasis.dicom.param.TlsOptions)

Example 4 with AdvancedParams

use of org.weasis.dicom.param.AdvancedParams in project karnak by OsiriX-Foundation.

the class DicomGatewayService method start.

public synchronized void start(DicomNode scpNode, GatewayParams params) throws Exception {
    if (isRunning()) {
        throw new IOException("Cannot start a DICOM Gateway because it is already running.");
    }
    storeScpForwardService.setStatus(0);
    storeScpForwardService.getCstoreSCP().setStatus(0);
    AdvancedParams options = Objects.requireNonNull(params).getParams();
    Connection conn = storeScpForwardService.getConnection();
    if (params.isBindCallingAet()) {
        options.configureBind(storeScpForwardService.getApplicationEntity(), conn, scpNode);
    } else {
        options.configureBind(conn, scpNode);
    }
    // configure
    options.configure(conn);
    options.configureTLS(conn, null);
    // Limit the calling AETs
    storeScpForwardService.getApplicationEntity().setAcceptedCallingAETitles(params.getAcceptedCallingAETitles());
    URL transferCapabilityFile = params.getTransferCapabilityFile();
    if (transferCapabilityFile != null) {
        storeScpForwardService.loadDefaultTransferCapability(transferCapabilityFile);
    } else {
        storeScpForwardService.getApplicationEntity().addTransferCapability(new TransferCapability(null, "*", TransferCapability.Role.SCP, "*"));
    }
    deviceService.start();
}
Also used : Connection(org.dcm4che3.net.Connection) IOException(java.io.IOException) AdvancedParams(org.weasis.dicom.param.AdvancedParams) TransferCapability(org.dcm4che3.net.TransferCapability) URL(java.net.URL)

Example 5 with AdvancedParams

use of org.weasis.dicom.param.AdvancedParams in project karnak by OsiriX-Foundation.

the class EchoService method buildEchoProcessParams.

/**
 * Build params for echo process call
 *
 * @param connectTimeout Connect Timeout
 * @param acceptTimeout Accept Timeout
 * @return parameters built
 */
private AdvancedParams buildEchoProcessParams(int connectTimeout, int acceptTimeout) {
    AdvancedParams params = new AdvancedParams();
    ConnectOptions connectOptions = new ConnectOptions();
    connectOptions.setConnectTimeout(connectTimeout);
    connectOptions.setAcceptTimeout(acceptTimeout);
    params.setConnectOptions(connectOptions);
    return params;
}
Also used : ConnectOptions(org.weasis.dicom.param.ConnectOptions) AdvancedParams(org.weasis.dicom.param.AdvancedParams)

Aggregations

AdvancedParams (org.weasis.dicom.param.AdvancedParams)7 ConnectOptions (org.weasis.dicom.param.ConnectOptions)6 IOException (java.io.IOException)2 DicomNode (org.weasis.dicom.param.DicomNode)2 DicomState (org.weasis.dicom.param.DicomState)2 PrintWriter (java.io.PrintWriter)1 URL (java.net.URL)1 Connection (org.dcm4che3.net.Connection)1 TransferCapability (org.dcm4che3.net.TransferCapability)1 DicomForwardDestination (org.karnak.backend.dicom.DicomForwardDestination)1 ForwardDestination (org.karnak.backend.dicom.ForwardDestination)1 ForwardDicomNode (org.karnak.backend.dicom.ForwardDicomNode)1 WebForwardDestination (org.karnak.backend.dicom.WebForwardDestination)1 DicomParam (org.weasis.dicom.param.DicomParam)1 TlsOptions (org.weasis.dicom.param.TlsOptions)1