@Override protected void customStateValidationAndMerge(Operation patch, ReservationTaskState patchBody, ReservationTaskState currentState) { if (SubStage.QUERYING_GLOBAL == patchBody.taskSubStage) { // In this case try global group instead of the provided one. currentState.tenantLinks = null; } // override without merging currentState.resourcePoolsPerGroupPlacementLinks = PropertyUtils.mergeProperty( currentState.resourcePoolsPerGroupPlacementLinks, patchBody.resourcePoolsPerGroupPlacementLinks); }
@Override public void handlePatch(Operation patch) { CompositeDescription currentState = getState(patch); CompositeDescription patchBody = patch.getBody(CompositeDescription.class); ServiceDocumentDescription docDesc = getDocumentTemplate().documentDescription; String currentSignature = Utils.computeSignature(currentState, docDesc); currentState.name = mergeProperty(currentState.name, patchBody.name); currentState.status = mergeProperty(currentState.status, patchBody.status); currentState.lastPublished = mergeProperty(currentState.lastPublished, patchBody.lastPublished); if (patchBody.parentDescriptionLink != null && patchBody.parentDescriptionLink.trim().isEmpty()) { currentState.parentDescriptionLink = null; } else { currentState.parentDescriptionLink = mergeProperty(currentState.parentDescriptionLink, patchBody.parentDescriptionLink); } currentState.descriptionLinks = mergeProperty(currentState.descriptionLinks, patchBody.descriptionLinks); currentState.customProperties = mergeCustomProperties( currentState.customProperties, patchBody.customProperties); String newSignature = Utils.computeSignature(currentState, docDesc); // if the signature hasn't change we shouldn't modify the state if (currentSignature.equals(newSignature)) { currentState = null; patch.setStatusCode(Operation.STATUS_CODE_NOT_MODIFIED); } patch.setBody(currentState).complete(); }
private void prepareContext(final CompositionTaskState state, final CompositeDescriptionExpanded compositeDesc) { if (compositeDesc == null) { getCompositeDescription(state, (compDesc) -> prepareContext(state, compDesc)); return; } state.customProperties = mergeProperty(compositeDesc.customProperties, state.customProperties); if (state.customProperties == null) { state.customProperties = new HashMap<>(); } // add contextId if not added String contextId; if ((contextId = state.customProperties.get(FIELD_NAME_CONTEXT_ID_KEY)) == null) { contextId = getSelfId(); state.customProperties.put(FIELD_NAME_CONTEXT_ID_KEY, contextId); } proceedTo(SubStage.CONTEXT_PREPARED, s -> { s.customProperties = state.customProperties; s.descName = compositeDesc.name; s.externalSchedulerTaskLink = getExternalSchedulerTaskLink(compositeDesc); }); }
String currentSignature = Utils.computeSignature(currentState, docDesc); currentState.name = PropertyUtils.mergeProperty(currentState.name, patchBody.name); currentState.compositeDescriptionLink = PropertyUtils.mergeProperty( currentState.compositeDescriptionLink, patchBody.compositeDescriptionLink); currentState.customProperties = PropertyUtils.mergeCustomProperties(currentState
@Override public void handlePatch(Operation patch) { if (!checkForBody(patch)) { return; } SslTrustCertificateState body = patch.getBody(SslTrustCertificateState.class); SslTrustCertificateState state = getState(patch); String stateCert = state.certificate; state.certificate = mergeProperty(state.certificate, body.certificate); boolean validated = ValidationUtils.validate(patch, () -> validateStateOnStart(state)); if (!validated) { return; } patch.setBody(state); if (isModified(patch, stateCert, body.certificate)) { patch.complete(); notifyLastUpdatedSslTrustDocumentService(); } else { patch.complete(); } }