001package org.dcm4che3.net.pdu; 002 003import java.io.IOException; 004 005import org.dcm4che3.util.StringUtils; 006 007public class AAssociateRJ extends IOException { 008 009 private static final long serialVersionUID = 6390401944858894694L; 010 011 public static final int RESULT_REJECTED_PERMANENT = 1; 012 public static final int RESULT_REJECTED_TRANSIENT = 2; 013 014 public static final int SOURCE_SERVICE_USER = 1; 015 public static final int SOURCE_SERVICE_PROVIDER_ACSE = 2; 016 public static final int SOURCE_SERVICE_PROVIDER_PRES = 3; 017 018 public static final int REASON_NO_REASON_GIVEN = 1; 019 public static final int REASON_APP_CTX_NAME_NOT_SUPPORTED = 2; 020 public static final int REASON_CALLING_AET_NOT_RECOGNIZED = 3; 021 public static final int REASON_CALLED_AET_NOT_RECOGNIZED = 7; 022 023 public static final int REASON_PROTOCOL_VERSION_NOT_SUPPORTED = 2; 024 025 public static final int REASON_TEMPORARY_CONGESTION = 1; 026 public static final int REASON_LOCAL_LIMIT_EXCEEDED = 2; 027 028 private static final String[] RESULTS = { 029 "0", 030 "1 - rejected-permanent", 031 "2 - rejected-transient" 032 }; 033 034 private static final String[] SOURCES = { 035 "0", 036 "1 - service-user", 037 "2 - service-provider (ACSE related function)", 038 "3 - service-provider (Presentation related function)" 039 }; 040 041 private static final String[] SERVICE_USER_REASONS = { 042 "0", 043 "1 - no-reason-given]", 044 "2 - application-context-name-not-supported", 045 "3 - calling-AE-title-not-recognized", 046 "4", 047 "5", 048 "6", 049 "7 - called-AE-title-not-recognized]", 050 }; 051 052 private static final String[] SERVICE_PROVIDER_ACSE_REASONS = { 053 "0", 054 "1 - no-reason-given", 055 "2 - protocol-version-not-supported", 056 }; 057 058 private static final String[] SERVICE_PROVIDER_PRES_REASONS = { 059 "0", 060 "1 - temporary-congestion]", 061 "2 - local-limit-exceeded]", 062 }; 063 064 private static final String[][] REASONS = { 065 StringUtils.EMPTY_STRING, 066 SERVICE_USER_REASONS, 067 SERVICE_PROVIDER_ACSE_REASONS, 068 SERVICE_PROVIDER_PRES_REASONS 069 }; 070 071 private final int result; 072 private final int source; 073 private final int reason; 074 075 public AAssociateRJ(int result, int source, int reason) { 076 super("A-ASSOCIATE-RJ[result: " + toString(RESULTS, result) 077 + ", source: " + toString(SOURCES, source) 078 + ", reason: " + toReason(source, reason) 079 + ']'); 080 this.result = result; 081 this.source = source; 082 this.reason = reason; 083 } 084 085 private static String toString(String[] ss, int i) { 086 try { 087 return ss[i]; 088 } catch (IndexOutOfBoundsException e) { 089 return Integer.toString(i); 090 } 091 } 092 093 private static String toReason(int source, int reason) { 094 try { 095 return toString(REASONS[source], reason); 096 } catch (IndexOutOfBoundsException e) { 097 return Integer.toString(reason); 098 } 099 } 100 101 public final int getResult() { 102 return result; 103 } 104 105 public final int getSource() { 106 return source; 107 } 108 109 public final int getReason() { 110 return reason; 111 } 112 113 @Override 114 public String toString() { 115 return getMessage(); 116 } 117}