2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.core.protocols.engdep.messages;
23 import org.onap.policy.apex.core.protocols.Message;
24 import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
25 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
28 * The Class UpdateModel is a message that requests an Apex engine to update its model using the data provided in the
31 * @author Liam Fallon (liam.fallon@ericsson.com)
33 public class UpdateModel extends Message {
34 private static final long serialVersionUID = 5885214410842753037L;
36 // The reply timeout value for update messages
37 private static final int UPDATE_MODEL_REPLY_TIMEOUT = 30000;
39 // Flags indicating whether conflicts in context should be ignored and whether the model should be forced even if it
41 private boolean ignoreConflicts = false;
42 private boolean forceInstall = false;
45 * Instantiates a new update model message.
47 * @param engineServiceKey the key of the engine service in which the model of all engines will be updated
49 public UpdateModel(final AxArtifactKey engineServiceKey) {
50 this(engineServiceKey, null, false, false);
54 * Instantiates a new update model message.
56 * @param engineServiceKey the key of the engine service in which the model of all engines will be updated
57 * @param messageData the message data that indicates to the Apex engine the manner in which its model should be
59 * @param ignoreConflicts true if conflicts between context in polices is to be ignored
60 * @param force true if the model is to be applied even if it is incompatible with the existing model
62 public UpdateModel(final AxArtifactKey engineServiceKey, final String messageData, final boolean ignoreConflicts,
63 final boolean force) {
64 super(EngDepAction.UPDATE_MODEL, engineServiceKey, messageData);
66 this.ignoreConflicts = ignoreConflicts;
67 this.forceInstall = force;
69 // Update messages have a longer timeout
70 setReplyTimeout(UPDATE_MODEL_REPLY_TIMEOUT);
74 * Check if context conflicts should be ignored.
76 * @return true if conflicts should be ignored
78 public boolean isIgnoreConflicts() {
79 return ignoreConflicts;
83 * Check if version checks should be overridden.
85 * @return true if version checks should be overridden
87 public boolean isForceInstall() {
95 public String toString() {
96 return "UpdateModel {" + super.toString() + "}[]";
103 public int hashCode() {
104 final int prime = 31;
105 int result = super.hashCode();
106 result = prime * result + (forceInstall ? 1231 : 1237);
107 result = prime * result + (ignoreConflicts ? 1231 : 1237);
115 public boolean equals(Object obj) {
119 if (!super.equals(obj)) {
123 UpdateModel other = (UpdateModel) obj;
124 if (forceInstall != other.forceInstall) {
127 return ignoreConflicts == other.ignoreConflicts;