001/*-
002 * #%L
003 * HAPI FHIR JPA Server
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.jpa.packages;
021
022import ca.uhn.fhir.context.FhirVersionEnum;
023import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
024import org.hl7.fhir.instance.model.api.IBaseResource;
025import org.hl7.fhir.utilities.npm.IPackageCacheManager;
026import org.hl7.fhir.utilities.npm.NpmPackage;
027
028import java.io.IOException;
029import java.util.Date;
030import java.util.List;
031
032public interface IHapiPackageCacheManager extends IPackageCacheManager {
033
034        NpmPackage installPackage(PackageInstallationSpec theInstallationSpec) throws IOException;
035
036        IBaseResource loadPackageAssetByUrl(FhirVersionEnum theFhirVersion, String theCanonicalUrl);
037
038        NpmPackageMetadataJson loadPackageMetadata(String thePackageId) throws ResourceNotFoundException;
039
040        PackageContents loadPackageContents(String thePackageId, String theVersion);
041
042        NpmPackageSearchResultJson search(PackageSearchSpec thePackageSearchSpec);
043
044        PackageDeleteOutcomeJson uninstallPackage(String thePackageId, String theVersion);
045
046        List<IBaseResource> loadPackageAssetsByType(FhirVersionEnum theFhirVersion, String theResourceType);
047
048        class PackageContents {
049
050                private byte[] myBytes;
051                private String myPackageId;
052                private String myVersion;
053                private Date myLastModified;
054
055                /**
056                 * Constructor
057                 */
058                public PackageContents() {
059                        super();
060                }
061
062                public byte[] getBytes() {
063                        return myBytes;
064                }
065
066                public PackageContents setBytes(byte[] theBytes) {
067                        myBytes = theBytes;
068                        return this;
069                }
070
071                public String getPackageId() {
072                        return myPackageId;
073                }
074
075                public PackageContents setPackageId(String thePackageId) {
076                        myPackageId = thePackageId;
077                        return this;
078                }
079
080                public String getVersion() {
081                        return myVersion;
082                }
083
084                public PackageContents setVersion(String theVersion) {
085                        myVersion = theVersion;
086                        return this;
087                }
088
089                public Date getLastModified() {
090                        return myLastModified;
091                }
092
093                public PackageContents setLastModified(Date theLastModified) {
094                        myLastModified = theLastModified;
095                        return this;
096                }
097        }
098}