convergence-project icon indicating copy to clipboard operation
convergence-project copied to clipboard

Model PUT REST call does not work for existing models.

Open mmacfadden opened this issue 5 years ago • 1 comments

Versions

  • Convergence Version: 1.0.0-rc.5

Describe the Bug A PUT to /api/rest/domains/convergence/default/models/<model-id> for an existing model fails in several ways.

  • If the model is open, the PUT will be rejected.
  • overrideWorld and userPermissions fields are ignored.
  • The version and modified time is not updated.
  • The model will now be out of sync with the history.

The reason for this is that the PUT currently does not require the model to be open, which means there is no model state, so we can only update the persistence store directly. We should actually be ensuring the model is open and then generating a synthetic operation to set the root of the model. This would insert an operation into the history, update the version and modified time, and work if the model was open or closed.

This will require some refactoring.

Step To Reproduce A code snippet or gist to reproduce the issue will greatly improve our response time

  1. Create a new model.
  2. Attempt to update it with a PUT.

Expected Behavior The model should be able to be updated whether it is open or closed, and the meta data and history should be properly maintained.

Work Around Leverage the RealTime API to update the model.

mmacfadden avatar Jan 23 '20 23:01 mmacfadden

We would need to issue an ObjectSetOperation to set the root model data. Generally this is pretty straight forward. Upon further review.... there are a few challenges thought:

  1. We need to load the whole model into memory if it is not loaded because we need to get the old value of the model to support undoing the operation.
  2. We also need to know the current version number.
  3. We also need to get a value-id prefix to use.
  4. The main issue is that in theory we need a session id to put in to the model. however there is no session.

The last part is problematic for a couple reasons.

  • If the model is open the concurrency control will need to process the operation and needs a connected client that it knows about.
  • If others have the model open they are going to get an operation from a session they don't even know exists.
  • There is no session object in the data base to link to.

mmacfadden avatar Jan 24 '20 15:01 mmacfadden