@Test(enabled = true) public void test010SerializeAddUserBarbossa() throws Exception { final String TEST_NAME = "test010SerializeAddUserBarbossa"; TestUtil.displayTestTile(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestClockwork.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); LensContext<UserType> context = createUserLensContext(); PrismObject<UserType> bill = prismContext.parseObject(USER_BARBOSSA_FILE); fillContextWithAddUserDelta(context, bill); clockwork.click(context, task, result); System.out.println("Context before serialization = " + context.debugDump()); LensContextType lensContextType = context.toLensContextType(); String xml = prismContext.xmlSerializer().serializeRealValue(lensContextType, SchemaConstants.C_MODEL_CONTEXT); display("Serialized form", xml); LensContextType unmarshalledContainer = prismContext.parserFor(xml).xml().parseRealValue(LensContextType.class); LensContext context2 = LensContext.fromLensContextType(unmarshalledContainer, context.getPrismContext(), provisioningService, task, result); display("Context after deserialization", context); assertEquals("Secondary deltas are not preserved - their number differs", context.getFocusContext().getSecondaryDeltas().size(), context2.getFocusContext().getSecondaryDeltas().size()); for (int i = 0; i < context.getFocusContext().getSecondaryDeltas().size(); i++) { assertEquals("Secondary delta #" + i + " is not preserved correctly", context.getFocusContext().getSecondaryDelta(i).debugDump(), context2.getFocusContext().getSecondaryDelta(i).debugDump()); } }
public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { if (context.getDebugListener() == null) { context.setDebugListener(debugListener); } try { XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result); ModelState state = context.getState(); if (state == ModelState.INITIAL) { if (debugListener != null) { debugListener.beforeSync(context); } metadataManager.applyRequestMetadata(context, now, task, result); context.getStats().setRequestTimestamp(now); audit(context, AuditEventStage.REQUEST, task, result); } boolean recompute = false; if (!context.isFresh()) { LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation"); recompute = true; } else if (context.getExecutionWave() > context.getProjectionWave()) { LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation"); recompute = true; } else if (state == ModelState.PRIMARY && ModelExecuteOptions.getInitialPartialProcessing(context.getOptions()) != null) { LOGGER.trace("Initial phase was run with initialPartialProcessing option -- forcing cleanup and recomputation"); recompute = true; } if (recompute) { context.cleanup(); projector.project(context, "PROJECTOR ("+state+")", task, result); } else if (context.getExecutionWave() == context.getProjectionWave()) { LOGGER.trace("Running projector for current execution wave"); projector.resume(context, "PROJECTOR ("+state+")", task, result); } else { LOGGER.trace("Skipping projection because the context is fresh and projection for current wave has already run"); } if (!context.isRequestAuthorized()) { authorizeContextRequest(context, task, result); } LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false); if (InternalsConfig.consistencyChecks) { try { context.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in clockwork, state="+state, e); } } if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) { context.checkEncrypted(); } switch (state) { case INITIAL: processInitialToPrimary(context, task, result); break; case PRIMARY: processPrimaryToSecondary(context, task, result); break; case SECONDARY: processSecondary(context, task, result); break; case FINAL: HookOperationMode mode = processFinal(context, task, result); if (debugListener != null) { debugListener.afterSync(context); } return mode; } result.recomputeStatus(); result.cleanupResult(); return invokeHooks(context, task, result); } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | ObjectAlreadyExistsException e) { processClockworkException(context, e, task, result); throw e; } }
Clockwork { public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { if (context.getDebugListener() == null) { context.setDebugListener(debugListener); } try { XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result); ModelState state = context.getState(); if (state == ModelState.INITIAL) { if (debugListener != null) { debugListener.beforeSync(context); } metadataManager.applyRequestMetadata(context, now, task, result); context.getStats().setRequestTimestamp(now); audit(context, AuditEventStage.REQUEST, task, result); } boolean recompute = false; if (!context.isFresh()) { LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation"); recompute = true; } else if (context.getExecutionWave() > context.getProjectionWave()) { LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation"); recompute = true; } else if (state == ModelState.PRIMARY && ModelExecuteOptions.getInitialPartialProcessing(context.getOptions()) != null) { LOGGER.trace("Initial phase was run with initialPartialProcessing option -- forcing cleanup and recomputation"); recompute = true; } if (recompute) { context.cleanup(); projector.project(context, "PROJECTOR ("+state+")", task, result); } else if (context.getExecutionWave() == context.getProjectionWave()) { LOGGER.trace("Running projector for current execution wave"); projector.resume(context, "PROJECTOR ("+state+")", task, result); } else { LOGGER.trace("Skipping projection because the context is fresh and projection for current wave has already run"); } if (!context.isRequestAuthorized()) { authorizeContextRequest(context, task, result); } LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false); if (InternalsConfig.consistencyChecks) { try { context.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in clockwork, state="+state, e); } } if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) { context.checkEncrypted(); } switch (state) { case INITIAL: processInitialToPrimary(context, task, result); break; case PRIMARY: processPrimaryToSecondary(context, task, result); break; case SECONDARY: processSecondary(context, task, result); break; case FINAL: HookOperationMode mode = processFinal(context, task, result); if (debugListener != null) { debugListener.afterSync(context); } return mode; } result.recomputeStatus(); result.cleanupResult(); return invokeHooks(context, task, result); } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | ObjectAlreadyExistsException e) { processClockworkException(context, e, task, result); throw e; } } }
Clockwork { public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { if (context.getDebugListener() == null) { context.setDebugListener(debugListener); } try { XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result); ModelState state = context.getState(); if (state == ModelState.INITIAL) { if (debugListener != null) { debugListener.beforeSync(context); } metadataManager.applyRequestMetadata(context, now, task, result); context.getStats().setRequestTimestamp(now); audit(context, AuditEventStage.REQUEST, task, result); } boolean recompute = false; if (!context.isFresh()) { LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation"); recompute = true; } else if (context.getExecutionWave() > context.getProjectionWave()) { LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation"); recompute = true; } else if (state == ModelState.PRIMARY && ModelExecuteOptions.getInitialPartialProcessing(context.getOptions()) != null) { LOGGER.trace("Initial phase was run with initialPartialProcessing option -- forcing cleanup and recomputation"); recompute = true; } if (recompute) { context.cleanup(); projector.project(context, "PROJECTOR ("+state+")", task, result); } else if (context.getExecutionWave() == context.getProjectionWave()) { LOGGER.trace("Running projector for current execution wave"); projector.resume(context, "PROJECTOR ("+state+")", task, result); } else { LOGGER.trace("Skipping projection because the context is fresh and projection for current wave has already run"); } if (!context.isRequestAuthorized()) { authorizeContextRequest(context, task, result); } LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false); if (InternalsConfig.consistencyChecks) { try { context.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in clockwork, state="+state, e); } } if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) { context.checkEncrypted(); } switch (state) { case INITIAL: processInitialToPrimary(context, task, result); break; case PRIMARY: processPrimaryToSecondary(context, task, result); break; case SECONDARY: processSecondary(context, task, result); break; case FINAL: HookOperationMode mode = processFinal(context, task, result); if (debugListener != null) { debugListener.afterSync(context); } return mode; } result.recomputeStatus(); result.cleanupResult(); return invokeHooks(context, task, result); } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | ObjectAlreadyExistsException e) { processClockworkException(context, e, task, result); throw e; } }  }
Clockwork { public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { if (context.getDebugListener() == null) { context.setDebugListener(debugListener); } try { XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result); ModelState state = context.getState(); if (state == ModelState.INITIAL) { if (debugListener != null) { debugListener.beforeSync(context); } metadataManager.applyRequestMetadata(context, now, task, result); context.getStats().setRequestTimestamp(now); audit(context, AuditEventStage.REQUEST, task, result); } boolean recompute = false; if (!context.isFresh()) { LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation"); recompute = true; } else if (context.getExecutionWave() > context.getProjectionWave()) { LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation"); recompute = true; } else if (state == ModelState.PRIMARY && ModelExecuteOptions.getInitialPartialProcessing(context.getOptions()) != null) { LOGGER.trace("Initial phase was run with initialPartialProcessing option -- forcing cleanup and recomputation"); recompute = true; } if (recompute) { context.cleanup(); projector.project(context, "PROJECTOR ("+state+")", task, result); } else if (context.getExecutionWave() == context.getProjectionWave()) { LOGGER.trace("Running projector for current execution wave"); projector.resume(context, "PROJECTOR ("+state+")", task, result); } else { LOGGER.trace("Skipping projection because the context is fresh and projection for current wave has already run"); } if (!context.isRequestAuthorized()) { authorizeContextRequest(context, task, result); } LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false); if (InternalsConfig.consistencyChecks) { try { context.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in clockwork, state="+state, e); } } if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) { context.checkEncrypted(); } switch (state) { case INITIAL: processInitialToPrimary(context, task, result); break; case PRIMARY: processPrimaryToSecondary(context, task, result); break; case SECONDARY: processSecondary(context, task, result); break; case FINAL: HookOperationMode mode = processFinal(context, task, result); if (debugListener != null) { debugListener.afterSync(context); } return mode; } result.recomputeStatus(); result.cleanupResult(); return invokeHooks(context, task, result); } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | ObjectAlreadyExistsException e) { processClockworkException(context, e, task, result); throw e; } }  LensDebugListener getDebugListener(); void setDebugListener(LensDebugListener debugListener); HookOperationMode run(LensContext<F> context, Task task, OperationResult result); HookOperationMode click(LensContext<F> context, Task task, OperationResult result); static void throwException(Throwable e); }
Clockwork { public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { if (context.getDebugListener() == null) { context.setDebugListener(debugListener); } try { XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result); ModelState state = context.getState(); if (state == ModelState.INITIAL) { if (debugListener != null) { debugListener.beforeSync(context); } metadataManager.applyRequestMetadata(context, now, task, result); context.getStats().setRequestTimestamp(now); audit(context, AuditEventStage.REQUEST, task, result); } boolean recompute = false; if (!context.isFresh()) { LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation"); recompute = true; } else if (context.getExecutionWave() > context.getProjectionWave()) { LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation"); recompute = true; } else if (state == ModelState.PRIMARY && ModelExecuteOptions.getInitialPartialProcessing(context.getOptions()) != null) { LOGGER.trace("Initial phase was run with initialPartialProcessing option -- forcing cleanup and recomputation"); recompute = true; } if (recompute) { context.cleanup(); projector.project(context, "PROJECTOR ("+state+")", task, result); } else if (context.getExecutionWave() == context.getProjectionWave()) { LOGGER.trace("Running projector for current execution wave"); projector.resume(context, "PROJECTOR ("+state+")", task, result); } else { LOGGER.trace("Skipping projection because the context is fresh and projection for current wave has already run"); } if (!context.isRequestAuthorized()) { authorizeContextRequest(context, task, result); } LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false); if (InternalsConfig.consistencyChecks) { try { context.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in clockwork, state="+state, e); } } if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) { context.checkEncrypted(); } switch (state) { case INITIAL: processInitialToPrimary(context, task, result); break; case PRIMARY: processPrimaryToSecondary(context, task, result); break; case SECONDARY: processSecondary(context, task, result); break; case FINAL: HookOperationMode mode = processFinal(context, task, result); if (debugListener != null) { debugListener.afterSync(context); } return mode; } result.recomputeStatus(); result.cleanupResult(); return invokeHooks(context, task, result); } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | ObjectAlreadyExistsException e) { processClockworkException(context, e, task, result); throw e; } }  LensDebugListener getDebugListener(); void setDebugListener(LensDebugListener debugListener); HookOperationMode run(LensContext<F> context, Task task, OperationResult result); HookOperationMode click(LensContext<F> context, Task task, OperationResult result); static void throwException(Throwable e);  }