1 /* 2 * Copyright 2009 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.openehealth.ipf.commons.ihe.xds.core.responses; 17 18 import org.apache.commons.lang3.StringUtils; 19 20 import javax.xml.bind.annotation.XmlEnum; 21 import javax.xml.bind.annotation.XmlEnumValue; 22 import javax.xml.bind.annotation.XmlType; 23 24 /** 25 * Error codes specified by the XDS specification. 26 * @author Jens Riemschneider 27 */ 28 @XmlType(name = "ErrorCode") 29 @XmlEnum(String.class) 30 public enum ErrorCode { 31 32 /* ----- codes from IHE ITI TF, Revision 7.0, Vol. 3, Table 4.1-11 ----- */ 33 /** Document entry exists in metadata with no corresponding attached document. */ 34 @XmlEnumValue("XDSMissingDocument") MISSING_DOCUMENT("XDSMissingDocument"), 35 /** MIME package contains MIME part with content-id header not found in metadata. */ 36 @XmlEnumValue("XDSMissingDocumentMetadata") MISSING_DOCUMENT_METADATA("XDSMissingDocumentMetadata"), 37 /** Repository was unable to access the registry. */ 38 @XmlEnumValue("XDSRegistryNotAvailable") REGISTRY_NOT_AVAILABLE("XDSRegistryNotAvailable"), 39 /** Internal error in registry. */ 40 @XmlEnumValue("XDSRegistryError") REGISTRY_ERROR("XDSRegistryError"), 41 /** Internal error in repository. */ 42 @XmlEnumValue("XDSRepositoryError") REPOSITORY_ERROR("XDSRepositoryError"), 43 /** The registry found a unique ID value that was used more than once within the submission. 44 * The Code Context indicates the duplicate unique ID. */ 45 @XmlEnumValue("XDSRegistryDuplicateUniqueIdInMessage") REGISTRY_DUPLICATE_UNIQUE_ID_IN_MESSAGE("XDSRegistryDuplicateUniqueIdInMessage"), 46 /** The repository found a unique ID value that was used more than once within the submission. 47 * The Code Context indicates the duplicate unique ID. */ 48 @XmlEnumValue("XDSRepositoryDuplicateUniqueIdInMessage") REPOSITORY_DUPLICATE_UNIQUE_ID_IN_MESSAGE("XDSRepositoryDuplicateUniqueIdInMessage"), 49 /** A unique ID received for a submission set or folder was not unique within the registry. 50 * The code context indicates the value of the non-unique ID and if it was a folder or submission set. 51 * Never returned for a document entry. */ 52 @XmlEnumValue("XDSDuplicateUniqueIdInRegistry") DUPLICATE_UNIQUE_ID_IN_REGISTRY("XDSDuplicateUniqueIdInRegistry"), 53 /** Document being registered was a duplicate (unique ID already in registry) but the hash codes 54 * do not match. The code context indicates the unique ID. */ 55 @XmlEnumValue("XDSNonIdenticalHash") NON_IDENTICAL_HASH("XDSNonIdenticalHash"), 56 /** Document being registered was a duplicate (uniqueId already in registry) 57 * but size does not match. CodeContext indicates UniqueId. */ 58 @XmlEnumValue("XDSNonIdenticalSize") NON_IDENTICAL_SIZE("XDSNonIdenticalSize"), 59 /** Too much activity in the registry to process the request. */ 60 @XmlEnumValue("XDSRegistryBusy") REGISTRY_BUSY("XDSRegistryBusy"), 61 /** Too much activity in the repository to process the request. */ 62 @XmlEnumValue("XDSRepositoryBusy") REPOSITORY_BUSY("XDSRepositoryBusy"), 63 /** Resources are too low within the registry to process the request. */ 64 @XmlEnumValue("XDSRegistryOutOfResources") REGISTRY_OUT_OF_RESOURCES("XDSRegistryOutOfResources"), 65 /** Resources are too low within the repository to process the request. */ 66 @XmlEnumValue("XDSRepositoryOutOfResources") REPOSITORY_OUT_OF_RESOURCES("XDSRepositoryOutOfResources"), 67 /** The registry detected an error in the meta data. The actor name indicates where 68 * error detected. The code context indicates the nature of the problem. */ 69 @XmlEnumValue("XDSRegistryMetadataError") REGISTRY_METADATA_ERROR("XDSRegistryMetadataError"), 70 /** The repository detected an error in the meta data. The actor name indicates where 71 * error detected. The code context indicates the nature of the problem. */ 72 @XmlEnumValue("XDSRepositoryMetadataError") REPOSITORY_METADATA_ERROR("XDSRepositoryMetadataError"), 73 /** A request produced too many results to finish the request. */ 74 @XmlEnumValue("XDSTooManyResults") TOO_MANY_RESULTS("XDSTooManyResults"), 75 /** Warning returned if extra meta data was present but not saved in the registry. */ 76 @XmlEnumValue("XDSExtraMetadataNotSaved") EXTRA_METADATA_NOT_SAVED("XDSExtraMetadataNotSaved"), 77 /** The patient ID referenced in the meta data is not known to the registry actor 78 * via the Patient Identity Feed or is unknown because of patient identifier merge 79 * or other reasons. The code context includes the value of the problematic patient ID. */ 80 @XmlEnumValue("XDSUnknownPatientId") UNKNOWN_PATIENT_ID("XDSUnknownPatientId"), 81 /** A patient ID that is required to be identical in the document entries, folders and 82 * submission sets contained in the request did not match. The code context indicates 83 * the value of the patient ID and the nature of the conflict. */ 84 @XmlEnumValue("XDSPatientIdDoesNotMatch") PATIENT_ID_DOES_NOT_MATCH("XDSPatientIdDoesNotMatch"), 85 /** The query ID provided in the request is not recognized. */ 86 @XmlEnumValue("XDSUnknownStoredQuery") UNKNOWN_STORED_QUERY("XDSUnknownStoredQuery"), 87 /** A required parameter to a stored query is missing. */ 88 @XmlEnumValue("XDSStoredQueryMissingParam") STORED_QUERY_MISSING_PARAM("XDSStoredQueryMissingParam"), 89 /** A parameter which only accepts a single value is coded with multiple values. */ 90 @XmlEnumValue("XDSStoredQueryParamNumber") STORED_QUERY_PARAM_NUMBER("XDSStoredQueryParamNumber"), 91 /** A register transaction was rejected because it submitted an association referencing 92 * a deprecated document. */ 93 @XmlEnumValue("XDSRegistryDeprecatedDocumentError") REGISTRY_DEPRECATED_DOCUMENT_ERROR("XDSRegistryDeprecatedDocumentError"), 94 /** The unique ID of a repository could not be resolved to a valid document repository 95 * or the value does not match that of the document repository. */ 96 @XmlEnumValue("XDSUnknownRepositoryId") UNKNOWN_REPOSITORY_ID("XDSUnknownRepositoryId"), 97 /** The document associated with the DocumentUniqueId is not available. */ 98 @XmlEnumValue("XDSDocumentUniqueIdError") DOCUMENT_UNIQUE_ID_ERROR("XDSDocumentUniqueIdError"), 99 /** A query resulted in returning information about multiple patients, 100 * which is forbidden because of security reasons. */ 101 @XmlEnumValue("XDSResultNotSinglePatient") RESULT_NOT_SINGLE_PATIENT("XDSResultNotSinglePatient"), 102 103 /* --- codes for XDR --- */ 104 /** An XDR Document Recipient did not process some part of the content. 105 * Specifically the parts not processed are Folder semantics. */ 106 @XmlEnumValue("PartialFolderContentNotProcessed") PARTIAL_FOLDER_CONTENT_NOT_PROCESSED("PartialFolderContentNotProcessed"), 107 /** An XDR Document Recipient did not process some part of the content. 108 * Specifically the parts not processed are Replacement semantics. */ 109 @XmlEnumValue("PartialReplaceContentNotProcessed") PARTIAL_REPLACE_CONTENT_NOT_PROCESSED("PartialReplaceContentNotProcessed"), 110 /** An XDR Document Recipient did not process some part of the content. 111 * Specifically the parts not processed are Transform semantics. */ 112 @XmlEnumValue("PartialTransformNotProcessed") PARTIAL_TRANSFORM_NOT_PROCESSED("PartialTransformNotProcessed"), 113 /** An XDR Document Recipient did not process some part of the content. 114 * Specifically the parts not processed are Append semantics. */ 115 @XmlEnumValue("PartialAppendContentNotProcessed") PARTIAL_APPEND_CONTENT_NOT_PROCESSED("PartialAppendContentNotProcessed"), 116 /** An XDR Document Recipient did not process some part of the content. 117 * Specifically the parts not processed are Relationship Association semantics. */ 118 @XmlEnumValue("PartialRelationshipContentNotProcessed") PARTIAL_RELATIONSHIP_CONTENT_NOT_PROCESSED("PartialRelationshipContentNotProcessed"), 119 /** An XDR Document Recipient did not process some part of the content. 120 * Specifically the parts not processed are Transform and Replace semantics. */ 121 @XmlEnumValue("PartialTransformReplaceNotProcessed") PARTIAL_TRANSFORM_REPLACE_NOT_PROCESSED("PartialTransformReplaceNotProcessed"), 122 /** An XDR Recipient queued the document for future manual matching to a patient. */ 123 @XmlEnumValue("DocumentQueued") DOCUMENT_QUEUED("DocumentQueued"), 124 /** The recipient has rejected this submission because it detected that one of the documents does 125 * not match the metadata or has failed other requirements for the document content. */ 126 @XmlEnumValue("InvalidDocumentContent") INVALID_DOCUMENT_CONTENT("InvalidDocumentContent"), 127 128 /* --- codes for XCA --- */ 129 /** A value for the homeCommunityId is not recognized */ 130 @XmlEnumValue("XDSUnknownCommunity") UNKNOWN_COMMUNITY("XDSUnknownCommunity"), 131 /** A value for the homeCommunityId is required and has not been specified */ 132 @XmlEnumValue("XDSMissingHomeCommunityId") MISSING_HOME_COMMUNITY_ID("XDSMissingHomeCommunityId"), 133 /** A community which would have been contacted was not available */ 134 @XmlEnumValue("XDSUnavailableCommunity") UNAVAILABLE_COMMUNITY("XDSUnavailableCommunity"), 135 136 /* --- codes for XCF --- */ 137 /** The requested document cannot be provided due to a transcoding/translation error. */ 138 @XmlEnumValue("TranscodingError") TRANSCODING_ERROR("TranscodingError"), 139 140 /* --- codes for MetaDataUpdate/Delete ITI-57/62 --- */ 141 /* --- When reporting this errors, the codeContext attribute of the RegistryError element shall --- 142 --- contain the id attribute of the metadata object causing the error. --- */ 143 144 /** General metadata update error. Use only when more specific error code is not available or appropriate. */ 145 @XmlEnumValue("XDSMetadataUpdateError") META_DATA_UPDATE_ERROR("XDSMetadataUpdateError"), 146 /** Update encountered error where Patient IDs did not match. */ 147 @XmlEnumValue("XDSPatientIDReconciliationError") PATIENT_ID_RECONCILIATION_ERROR("XDSPatientIDReconciliationError"), 148 /** Document Registry/Recipient cannot decode the requested metadata update. */ 149 @XmlEnumValue("XDSMetadataUpdateOperationError") META_DATA_UPDATE_OPERATION_ERROR("XDSMetadataUpdateOperationError"), 150 /** The version number included in the update request did not match the existing object. 151 * One cause of this is multiple simultaneous update attempts. */ 152 @XmlEnumValue("XDSMetadataVersionError") META_DATA_VERSION_ERROR("XDSMetadataVersionError"), 153 /** The Document Repository was not able to remove the document. The codeContext shall indicate 154 * the DocumentUniqueId of the document that caused the error.*/ 155 @XmlEnumValue("XDSRemoveDocumentsError") REMOVE_DOCUMENTS_ERROR("XDSRemoveDocumentsError"), 156 /** The recipient cannot resolve an entryUUID reference in the transaction. */ 157 @XmlEnumValue("UnresolvedReferenceException") UNRESOLVED_REFERENCE_EXCEPTION("UnresolvedReferenceException"), 158 /** An entryUUID passed in the Delete Document Set transaction is referenced by an Association 159 * sourceObject or targetObject attribute. */ 160 @XmlEnumValue("ReferencesExistException") REFERENCE_EXISTS_EXCEPTION("ReferencesExistException"), 161 /** A metadata object is no longer referenced by any Association. */ 162 @XmlEnumValue("XDSUnreferencedObjectException") UNREFERENCED_OBJECT_EXCEPTION("XDSUnreferencedObjectException"), 163 /** Error detected by the Document Registry during a document replacement. 164 * @deprecated this error code is deprecated by IHE 165 */ 166 @Deprecated // error code XDSReplaceFailed is deprecated by IHE 167 @XmlEnumValue("XDSReplaceFailed") REPLACE_FAILED("XDSReplaceFailed"), 168 169 /* --- codes for ITI-16 (obsolete XDS.a profile) --- */ 170 /** An error occurred when executing an SQL query. */ 171 @XmlEnumValue("XDSSqlError") SQL_ERROR("XDSSqlError"), 172 173 /* --- special value for custom user-defined error codes --- */ 174 @XmlEnumValue("_UserDefined") _USER_DEFINED("_UserDefined"); 175 176 177 private final String opcode; 178 179 ErrorCode(String opcode) { 180 this.opcode = opcode; 181 } 182 183 /** 184 * @return string representation for usage in ebXML values. 185 */ 186 public String getOpcode() { 187 return opcode; 188 } 189 190 /** 191 * <code>null</code>-safe version of {@link #getOpcode()}. 192 * @param errorCode 193 * the error code. Can be <code>null</code>. 194 * @return the string representation or <code>null</code> if errorCode was <code>null</code>. 195 */ 196 public static String getOpcode(ErrorCode errorCode) { 197 return errorCode != null ? errorCode.getOpcode() : null; 198 } 199 200 /** 201 * Returns the error code that corresponds to the given opcode. 202 * @param opcode 203 * the opcode. Can be <code>null</code>. 204 * @return the error code. 205 * <code>null</code> when the opcode is <code>null</code> or empty, 206 * {@link #_USER_DEFINED} when the code is not a standard one. 207 */ 208 public static ErrorCode valueOfOpcode(String opcode) { 209 if (StringUtils.isBlank(opcode)) { 210 return null; 211 } 212 213 for (ErrorCode code : values()) { 214 if (opcode.equals(code.getOpcode())) { 215 return code; 216 } 217 } 218 219 return _USER_DEFINED; 220 } 221 }