Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 1 addition & 56 deletions fhir-model/src/main/java/com/ibm/fhir/model/util/FHIRUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -33,8 +29,6 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.crypto.KeyGenerator;

import com.ibm.fhir.exception.FHIRException;
import com.ibm.fhir.exception.FHIROperationException;
import com.ibm.fhir.model.config.FHIRModelConfig;
Expand All @@ -59,7 +53,6 @@
import com.ibm.fhir.model.type.code.DataAbsentReason;
import com.ibm.fhir.model.type.code.IssueSeverity;
import com.ibm.fhir.model.type.code.IssueType;
import com.ibm.fhir.model.type.code.ResourceType;
import com.ibm.fhir.model.visitor.Visitable;

import jakarta.json.Json;
Expand All @@ -72,6 +65,7 @@
* Utility methods for working with the FHIR object model.
*/
public class FHIRUtil {
private static final Logger log = Logger.getLogger(FHIRUtil.class.getName());
public static final Pattern REFERENCE_PATTERN = buildReferencePattern();
public static final Extension DATA_ABSENT_REASON_UNKNOWN = Extension.builder()
.url("http://hl7.org/fhir/StructureDefinition/data-absent-reason")
Expand All @@ -80,10 +74,7 @@ public class FHIRUtil {
public static final com.ibm.fhir.model.type.String STRING_DATA_ABSENT_REASON_UNKNOWN = com.ibm.fhir.model.type.String.builder()
.extension(DATA_ABSENT_REASON_UNKNOWN)
.build();
@Deprecated
private static final SecureRandom RANDOM = new SecureRandom();
private static final JsonBuilderFactory BUILDER_FACTORY = Json.createBuilderFactory(null);
private static final Logger log = Logger.getLogger(FHIRUtil.class.getName());
public static final OperationOutcome ALL_OK = OperationOutcome.builder()
.issue(Issue.builder()
.severity(IssueSeverity.INFORMATION)
Expand Down Expand Up @@ -537,31 +528,6 @@ public static <T extends Resource> T addTag(T resource, Coding tag) {
return updatedResource;
}

/**
* Returns the resource type (as a String) of the specified resource.
*
* @param resource
* the resource
* @return the name of the resource type associated with the resource
* @deprecated use {@link ModelSupport.getTypeName(Class<?>)}
*/
@Deprecated
public static String getResourceTypeName(Resource resource) {
return resource.getClass().getSimpleName();
}

/**
* @return a list of all resource type names, including abstract supertypes
* @implNote this list does not include "logical" resources like {code MetadataResource}
* @deprecated use {@link ModelSupport.getResourceTypes()}
*/
@Deprecated
public static List<String> getResourceTypeNames() {
return Arrays.stream(ResourceType.Value.values())
.map(ResourceType.Value::value)
.collect(Collectors.toList());
}

/**
* Determine if any of the issues in the list of issues are failure issues
*
Expand Down Expand Up @@ -593,27 +559,6 @@ public static boolean isFailure(IssueSeverity severity) {
}
}

/**
* Generate a random key using the passed algorithm or, if that algorithm isn't supported, a random 32 byte value.
* In either case, the resulting value is encoded as a Base64 string before returning.
*
* @return a base64-encoded random key string
* @deprecated we plan to remove this from FHIRUtil in a future release
*/
@Deprecated
public static String getRandomKey(String algorithm) {
try {
KeyGenerator keyGen = KeyGenerator.getInstance(algorithm);
keyGen.init(256);
return Base64.getEncoder().encodeToString(keyGen.generateKey().getEncoded());
} catch (NoSuchAlgorithmException e) {
log.warning("Algorithm '" + algorithm + "' is not supported; using SecureRandom instead");
byte[] buffer = new byte[32];
RANDOM.nextBytes(buffer);
return Base64.getEncoder().encodeToString(buffer);
}
}

/**
* Create a self-contained bundle from the passed map of resources, replacing Resource.id values and
* references with a generated UUID.
Expand Down

This file was deleted.