Orbeon 4.5 - How to pass request parameters? - orbeon

We are upgrading from Orbeon 3.9 to 4.5.
In Orbeon 3.9, we were passing request parameters to the send success URI (oxf.fr.detail.send.success.uri) when the user clicks on a custom submit button. We have done this by modifying persistence-model.xml.
Following is the code part which we used in 3.9:
<xforms:model id="fr-persistence-model"
<xforms:instance id="x3params">
<data xmlns="">
<customerid/>
</data>
</xforms:instance>
<xforms:action ev:event="xforms-model-construct-done" if="$app != '*' and $form != '*'">
<xforms:setvalue ref="instance('g3params')/customerid" value="xxforms:get-request-parameter('customerid')" />
<xxforms:variable name="g3customerId" as="xs:string" select="instance('g3params')/customerid"/>
<xforms:submission id="fr-workflow-send-submission"
resource="{$workflow-success-uri}?fr-app={$app}&form={$form}&docid={$document}&customerid={$g3customerId}"
relevant="{xxforms:property(string-join(('oxf.fr.detail.send.success.prune', $app, $form), '.'))}"
validate="false" method="{$workflow-success-method}"
serialization="{if ($workflow-success-method = 'get') then 'none' else 'application/xml'}"
ref="if (instance('fr-workflow-send-instance') != '') then instance('fr-workflow-send-instance') else xxforms:instance('fr-form-instance')"
replace="all"/>
In Orbeon 4.5, I used the save-final process for a custom submit.
Since fr-workflow-send-submission is removed in 4.5, how can I pass the request parameters to the send success URI?
Following is my properties-local.xml:
<property as="xs:boolean" name="oxf.fr.detail.send.pdf" value="false"/>
<property as="xs:boolean" name="oxf.fr.email.attach-pdf" value="false"/>
<property as="xs:anyURI" name="oxf.fr.detail.send.success.uri.Preconstruction.*" value="http://localhost:8080/webapp/new"/>
<property as="xs:string" name="oxf.fr.detail.send.success.method.*.*" value="post"/>
<property as="xs:boolean" name="oxf.fr.detail.send.success.prune.*.*" value="false"/>

You can use XPath value templates in the service URL:
<property
as="xs:string"
name="oxf.fr.detail.send.success.uri.Preconstruction.*"
value="http://localhost:8080/webapp/new?customerid={xxf:get-request-parameter('customerid')}"/>
Orbeon Forms passes app, form and document by default now. The only thing is that I notice that in your code you use fr-app, form, and docid. It is probably better to switch to using the standard names used by Orbeon Forms now (so app, form and document).

Related

How can one register a Direct2D custom effect that has variable numbers of inputs?

I am making custom effects with Direct2D, based on Microsoft Learn page. The problem is that, I wanted to make a Direct2D effect which support a variable input count, like Direct2D Composite Effect, while the XML registration string used for ID2D1Factory1::RegisterEffectFromString seemed to take fixed <Input> properties. What should be done in XML registration string?
My XML is almost the same as one from Microsoft Learn page. Still I will provide mine.
auto xml_AxisRotation = XML(
<?xml version='1.0'?>
<Effect>
<!--System Properties-->
<Property name='DisplayName' type='string' value='MultiInput Effect'/>
<Property name='Author' type='string' value='Nan_ok'/>
<Property name='Category' type='string' value='None'/>
<Property name='Description' type='string' value='asdfasdfasdf'/>
<Inputs>
<Input name='Source1'/>
<Input name='Source2'/>
//...?
</Inputs>
<!--Custom Properties go here-->
<Property name='Mode' type='int32'>
<Property name='DisplayName' type='string' value='Mode'/>
<Property name='Default' type='int32' value='1'/>
</Property>
</Effect>
);
I once deliberately omitted the whole <Input> part, but it failed to perform; E_INVALIDARG has been returned.
The XML registration and actual Direct2D effect's input taking worked differently. By proper implementing ID2D1EffectImpl::SetGraph and calling ID2D1Effect::SetInputCount, I was able to set variable numbers of target.
It seemed ok to leave <Inputs> with no <Input> property. here is my XML example.
auto xml_AxisRotation = XML(
<?xml version='1.0'?>
<Effect>
<!--System Properties-->
<Property name='DisplayName' type='string' value='MultiInput Effect'/>
<Property name='Author' type='string' value='Nan_o'/>
<Property name='Category' type='string' value='None'/>
<Property name='Description' type='string' value='asdfasdfasdf'/>
<Inputs> </Inputs> <!--Leaving like this is ok-->
<!--Custom Properties go here-->
<Property name='Mode' type='int32'>
<Property name='DisplayName' type='string' value='Mode'/>
<Property name='Default' type='int32' value='1'/>
</Property>
</Effect>
);

Orbeon header authentication

I'm currently using Orbeon 2019.2 CE version
I'm trying to configure header-driven method for access control without using Liferay or default Login/Logout form in Orbeon.
I have already set these properties in properties-dev.xml
I'm have 2 roles (form-builder, form-viewer) sending via My-Roles-Header.
<property as="xs:string" name="oxf.fr.authentication.method" value="header"/>
<property as="xs:boolean" name="oxf.fr.authentication.header.sticky" value="true"/>
<property as="xs:string" name="oxf.fr.authentication.header.username" value="My-Username-Header"/>
<property as="xs:string" name="oxf.fr.authentication.header.group" value="My-Group-Header"/>
<property as="xs:string" name="oxf.fr.authentication.header.roles.split" value="(\s*[,\|]\s*)+"/>
<property as="xs:string" name="oxf.fr.authentication.header.roles" value="My-Roles-Header"/>
<property as="xs:string" name="oxf.xforms.forward-submission-headers" value="My-Username-Header My-Group-Header My-Roles-Header"/>
<property as="xs:string" name="oxf.http.forward-headers" value="My-Username-Header My-Group-Header My-Roles-Header"/>
However, I'm still able to access form builder and form runner without sending My-Username-Header My-Group-Header My-Roles-Header headers. It should redirect me to 403 page
Form Runner: the default is that each individual form must have permissions enabled or the form will be public. Make sure that "Enable permission for this form" is selected in Form Builder (doc).
Form Builder: see Form Builder permissions.

How to add google OAuth2.0 support in my CAS server

I am using jasig cas4.0 server. I have implemented the Facebook oAuth2.0 support in my cas server and it works correctly. Now, I want to add Google oauth support (Google2Client) in the same CAS-server.
1) I created a new Project in console.developers.google.com, created a new client id under the OAuth with redirect uri to https://rajan.com:1443/cas/login (which actually points to localhost)
2) I added this to my applicationcontext.xml
<bean id="google1" class="org.pac4j.oauth.client.Google2Client">
<property name="key" value="<<CLIENT_ID>>" />
<property name="secret" value="<CLIENT_SECRET" />
<property name="scope" value="email" />
<property name="fields" value="id,name,first_name,middle_name,last_name,gender,email" />
</bean>
I also registered this bean in the clients
<bean id="clients" class="org.pac4j.core.client.Clients">
<property name="callbackUrl" value="https://rajan.com:1443/cas/login" />
<property name="clients">
<list>
<ref bean="facebook1" />
<ref bean="google1" />
</list>
</property>
</bean>
3) And finally, I added this in casLoginView.jsp
Authenticate with Facebook <br />
Authenticate with Google <br />
But, When I open the cas login view in the browser, the href for Google contains "https://rajan.com:1443/cas/login?service=https%3A%2F%2Frajan.com%3A2443%2FCasClientSimple%2F" instead of Google Oauth url. The facebook link works fine.
Could someone help me what I am missing here.
Thank you.
I checked the Google2OauthClient. There were no fields property.
So, just deleting the fields property in the above bean worked.
I also changed the field email with EMAIL_AND_PROFILE

Orbeon localisation

I translated the necessary files for Dutch but apparently the runner still shows the error section in English.
I looked at both the runner and fb resource.xml but couldn't find the string 'Your form contains the following errors'.
I also have this entries in the properties-local.xml
<property as="xs:string" name="oxf.fr.available-languages.orbeon.builder" value="nl en"/>
<property as="xs:string" name="oxf.fr.default-language.orbeon.builder" value="nl"/>
<property as="xs:string" name="oxf.fr.default-language.orbeon.*" value="nl"/>
<property as="xs:string" name="oxf.fr.default-language.*.*" value="nl"/>
It depends which version you are using:
up to Orbeon Forms 4.2, resources.xml does contain that message
starting Orbeon Forms 4.3, resources.xml contains a more complex formatted string

Spring ws XSD validation

Currently i am implementing web services using Spring-ws . Here i am struck with xsd validation . For xsd validation i am using the following configruation
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="xsdSchema" ref="schema" />
<property name="validateRequest" value="true" />
<property name="validateResponse" value="true" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/ProductSchema.xsd" />
</bean>
Here i am passing the xsd file during bean initialization . Is there any way for me to send this(ProductSchema.xsd) xsd file dynamically. Because I will comes to know which xsd file needs to send based on the input payload.
Please help me. Thanks in advance
I don't know how many XSD's you have, but perhaps you can define imports in ProductSchema.xsd to include the others. That's at least how I've got it set up.
For example:
<import namespace="http://namespace" schemaLocation="data.xsd" />
I'm not quite sure of what you are trying to do.
But you can make different endpoints/methods that matches different payloads by annotating the handler method with a localPart that matches the name of an element i the payload:
#Endpoint
public class MyEndpoint {
#PayloadRoot(namespace = NAMESPACE_URI, localPart = "NameOfMyXmlRequestElement")
#ResponsePayload
public MyResponse handleMyRequest(#RequestPayload MyRequest MyRequest) throws Exception {
...
A recived request can then be unmarshalled/validated using a specific schema:
<bean id="myJaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>mydomain.model.oxm.MyRequest</value>
<value>mydomain.model.oxm.MyResponse</value>
</list>
</property>
<property name="schema" ref="MyServiceSchema" />
</bean>
<bean id="MyServiceSchema" class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="WEB-INF/schemas/MyService.xsd" />
</bean>
The MyRequest class must be annotated to work with the Jaxb2marshaller, #XmlRootElement(name="MyRequest") etc...

Resources