Quantcast

Template versioning and attachments

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Template versioning and attachments

bwallis42
I'm having problems with attachments to form templates with versioning enabled.

My persistence layer is written to support versioning. I do need to know what the template version number is when an attachment is fetched which I expect to find in the orbeon-form-definition-version request header.

I can create two versions of a template with a different static image attached to each (versions are 1 and 2).

When I create new forms from either of the two versions of the template I get the correct static image attachments. The 'new' url to create the form and the subsequent sequence of calls to my persistence layer are as follows (the "test" query parameter is one we use internally). I've also shown the value of the orbeon-form-definition-version request header when it is in the request.

This sequence is for version 2 of the template

GET  /orbeon/fr/CPF/aaaa-test:2/new?test=true&form-version=2

GET  /persistence/cpf/crud/CPF/aaaa-test:2/form/form.xhtml
            orbeon-form-definition-version: 2

POST /persistence/cpf/search/CPF/aaaa-test:2

GET /persistence/cpf/crud/CPF/aaaa-test/form/2dc2f443696b79d9f4759553315307f8a5038189.bin
            orbeon-form-definition-version: 2

And this one is for version 1.

GET /orbeon/fr/CPF/aaaa-test:1/new?test=true&form-version=1

GET /persistence/cpf/crud/CPF/aaaa-test:1/form/form.xhtml
            orbeon-form-definition-version: 1

POST /persistence/cpf/search/CPF/aaaa-test:1

GET /persistence/cpf/crud/CPF/aaaa-test/form/98cbc8279aa7396942fe5a84ae2618827d078f93.bin
        orbeon-form-definition-version: 1

Now, when I try to edit the two different versions I get different results. If I edit version 1 it is fine, if I edit version 2 I don't get the attachment. The reason is that the value of the orbeon-form-definition-version request header is wrong. It seems to always be 1 when editing a template.

This is the sequence of requests when I edit version 1 (this one shows the correct attachment in the editor)

GET /orbeon/fr/orbeon/builder/edit/1417:1?form-version=1

GET /persistence/cpf/crud/orbeon/builder/data/1417:1/data.xml

GET /persistence/cpf/crud/CPF/aaaa-test/form/98cbc8279aa7396942fe5a84ae2618827d078f93.bin
            orbeon-form-definition-version: 1

But when I edit version 2 I don't see the attached image

GET /orbeon/fr/orbeon/builder/edit/1417:2?form-version=2

GET /persistence/cpf/crud/orbeon/builder/data/1417:2/data.xml

GET /persistence/cpf/crud/CPF/aaaa-test/form/2dc2f443696b79d9f4759553315307f8a5038189.bin
            orbeon-form-definition-version: 1

Note that when orbeon tries to fetch the attachment (and the id is correct) it is telling me that this if for version 1 of the form, but I'm editing version 2. There is no such attachment for version 1.

I know that the id for the attachment is probably unique and I might be able to use that without a version to find it but my persistence doesn't work that way. The form template and its attachments are kept together.

Is this a bug or do I need to re-think how I store the template attachments?

thanks,
brian...


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Template versioning and attachments

Alessandro  Vernet
Administrator
Hi Brian,

Yes, this is a bug, which also happens with the built-in implementation of the persistence API. I've created:

https://github.com/orbeon/orbeon-forms/issues/3170

This is interesting, and we'll give some thoughts as to how this could be fixed. In the meantime, if you need a quick workaround, in your implementation of the persistence API, maybe you could ignore the version number when attachments to published forms are retrieved. You'll let me know if this "works" for you (in the sense that the image loads, not that this is clean!).

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Template versioning and attachments

bwallis42
Thanks for confirming that Alex, I was worried that I had misunderstood how this should work.

I have a work around for the moment, when asked for a form attachment I am ignoring the value in the header (as suggested) and just search all versions in my persistence store, backwards from the latest version. This seems to work for now and should be reasonably efficient in most real world cases since the latest version is usually the correct one.

Your ticket talks about a library form but that is not my case, I don't use library forms. In my case it is just two versions of a single form template with a static image attached. I haven't tried it but I assume this will also fail for other attachments to form templates.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Template versioning and attachments

Alessandro  Vernet
Administrator
Hi Brian,

The ticket is about the "library", because my understanding was that
you were talking about section templates in your description of the
issue. Are you saying that you're also seeing a problem if you don't
use any section template in your form?

Alex

On Tue, Apr 18, 2017 at 7:53 PM, bwallis42
<[hidden email]> wrote:

> Thanks for confirming that Alex, I was worried that I had misunderstood how
> this should work.
>
> I have a work around for the moment, when asked for a form attachment I am
> ignoring the value in the header (as suggested) and just search all versions
> in my persistence store, backwards from the latest version. This seems to
> work for now and should be reasonably efficient in most real world cases
> since the latest version is usually the correct one.
>
> Your ticket talks about a library form but that is not my case, I don't use
> library forms. In my case it is just two versions of a single form template
> with a static image attached. I haven't tried it but I assume this will also
> fail for other attachments to form templates.
>
> --
> View this message in context: http://discuss.orbeon.com/Template-versioning-and-attachments-tp4662363p4662367.html
> Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Template versioning and attachments

bwallis42
That's right, we don't use section templates (yet).

This is purely for a form template with an attached static image (or other attachment). The scenario I described above only involved a form template.

Am I using the terminology wrong? We refer to forms and form templates to distinguish between an actual instance of the form data and the template defining the controls and layout of the form.

brian...
Loading...