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