001/*-
002 * #%L
003 * HAPI FHIR - Server Framework
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.rest.server.messaging;
021
022import ca.uhn.fhir.context.FhirContext;
023import ca.uhn.fhir.interceptor.model.RequestPartitionId;
024import ca.uhn.fhir.rest.api.server.RequestDetails;
025import org.apache.commons.lang3.builder.ToStringBuilder;
026import org.hl7.fhir.instance.model.api.IBaseResource;
027
028public class ResourceOperationMessage extends BaseResourceModifiedMessage {
029
030        public ResourceOperationMessage() {}
031
032        public ResourceOperationMessage(
033                        FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
034                super(theFhirContext, theResource, theOperationType);
035        }
036
037        public ResourceOperationMessage(
038                        FhirContext theFhirContext,
039                        IBaseResource theNewResource,
040                        OperationTypeEnum theOperationType,
041                        RequestDetails theRequest) {
042                super(theFhirContext, theNewResource, theOperationType, theRequest);
043        }
044
045        public ResourceOperationMessage(
046                        FhirContext theFhirContext,
047                        IBaseResource theNewResource,
048                        OperationTypeEnum theOperationType,
049                        RequestDetails theRequest,
050                        RequestPartitionId theRequestPartitionId) {
051                super(theFhirContext, theNewResource, theOperationType, theRequest, theRequestPartitionId);
052        }
053
054        /**
055         * If you are using a non-fhir-resource payload, you may set the payload directly here instead of using the constructor.
056         * @param thePayload the payload of the message.
057         */
058        public void setPayload(String thePayload) {
059                this.myPayload = thePayload;
060        }
061
062        @Override
063        public String toString() {
064                return new ToStringBuilder(this)
065                                .append("operationType", myOperationType)
066                                .append("payloadId", myPayloadId)
067                                .append("partitionId", myPartitionId)
068                                .toString();
069        }
070}