Spring Webflow - How to Get List of FLOW IDs - spring-webflow

What is the best way to get the full list of FLOW IDs generated by Spring Webflow?
Here is my configuration:
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices"
base-path="/WEB-INF/pageFlows">
<webflow:flow-location-pattern value="/**/*-flow.xml"/>
</webflow:flow-registry>
[UPDATE 1] I should clarify that I want to do this in Java code, not by inspecting my configuration.
[UPDATE 2] answer: requestContext.getActiveFlow().getApplicationContext()

List of flow ids can be identified by the way they are defined in flow-registry. By default, flows will be assigned registry identifiers equal to their filenames minus the file extension, unless a registry base path is defined.
Let me explain this with examples:
Scenario 1:
flow-location and base-path is not specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/pageFlows/example.xml" />
</webflow:flow-registry>
Flow id: example
Scenario 2:
flow-location-pattern and base-path is not specified :
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location-pattern value="/WEB-INF/pageFlows/**/*-flow.xml"/>
</webflow:flow-registry>
If you have flows like /WEB-INF/pageFlows/example1-flow.xml, /WEB-INF/pageFlows/example2-flow.xml, flow ids are: example1-flow, example2-flow respectively.
Scenario 3:
Your own id is specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/pageFlows/example.xml" id="myExampleId" />
</webflow:flow-registry>
Flow id: myExampleId
Scenario 4:
base-path is specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location path="/pageFlows/example.xml" />
</webflow:flow-registry>
Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name.
Flow id: pageFlows
Scenario 5:
flow-location-pattern and base-path is specified:
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name.
So if you have flows located in /pageFlows1/example1, /pageFlows2/example2 directories within WEB-INF, flow ids are: pageFlows1, pageFlows2 respectively.
EDIT :
To get flow ids programmatically:
Assuming your flow controller and flowexecutor definitions as below in webflow-config xml file:
<bean name="flowController" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
//flowRegistry is alredy mentioned in your question
<flow:executor id="flowExecutor" registry-ref="flowRegistry">
<flow:repository type="continuation" max-conversations="1" max-continuations="30" />
</flow:executor>
You can retrieve flow definition ids registered as below:
(I am calling this from a Controller which extends AbstractController, thats why you see getServletContext() method)
ApplicationContext context =
(ApplicationContext)getServletContext().getAttribute(
DispatcherServlet.SERVLET_CONTEXT_PREFIX + "yourWebContextName");
FlowController controller = (FlowController)context.getBean("flowController");
FlowExecutorImpl flowExecutorImpl = (FlowExecutorImpl)controller.getFlowExecutor();
FlowDefinitionRegistryImpl flowDefinitionRegistryImpl = (FlowDefinitionRegistryImpl)flowExecutorImpl.getDefinitionLocator();
//Assuming you have log configured
log.info("Registered Flow Ids are:"+flowDefinitionRegistryImpl.getFlowDefinitionIds());
FlowController has access to FlowExecutor(initial point of entry for webflow). FlowExecutor has access to flowDefinitionRegistry where all flows are registered before being served to requests.
Hope this helps.

Related

How to retrieve Itinerary remarks with GetReservationsRQ Api?

Running the command I¥ command returns:
2 AA1579X 16SEP 5 DFWORD HF1 0625 0846 /DCBA*SDAZXT /E
I have successfully sent a request using GetReservationRQ. Asking for the remarks sections but I am getting the result above which I would expect. (I assumed this is the right section and have tried Itinerary too, see below)
<GetReservationRQ version="1.1.0" xmlns="http://services.sabre.com/sp/updatereservation/v1_1">
<Profile>
<UniqueID id="......."/>
</Profile>
<SubjectAreas>
<SubjectArea>REMARKS</SubjectArea>
</SubjectAreas>
<ReturnOptions>
<ViewName>Default</ViewName>
<ResponseFormat>STL</ResponseFormat>
</ReturnOptions>
</GetReservationRQ>
Which returns 2 remarks as part of the response:
<Remarks>
<Remark id="44" index="1" type="HS">
<RemarkLines>
<RemarkLine>
<Text>POSSIBLE DUPE BOOKING. SEE PNR JZXWEI JBVFYC HUSTLM</Text>
</RemarkLine>
</RemarkLines>
</Remark>
<Remark id="45" index="2" type="HS">
<RemarkLines>
<RemarkLine>
<Text>POSSIBLE DUPE BOOKING. SEE PNR KDCFKD KQLLXF</Text>
</RemarkLine>
</RemarkLines>
</Remark>
</Remarks>
However as you can see they are not the same remark as when I run the command I¥. What am I doing wrong?
Here are links to the sabre documentation:
https://developer.sabre.com/docs/soap_apis/management/itinerary/Retrieve_Itinerary/help_doc?page=get-reservation-request-and-response-structure
Which says:
REMARKS Allows to display remark information (supported types: REG, HD, HS, CLIADR, DELADR, INVOICE, ITINERARY, INTERFACE, CODED_A, PRTONTKT, CORPORATE, FOP, QQ, FILLER, ITINSEGASSOC)

adding 1 user with htpasswd in 2 different servers using ssh connection

i'm working with apache camel and i want to add one user in two differents servers.And i want to test if ssh.redundancy=true.This is my code :
<simple ${headers.op} == 1</simple>
<doTry id="try-cmd-httpd">
<setBody id="httpd.cmd.htpasswd">
<simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
</setBody>
**<to id="to_exec_htpaswd" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host}}:{{ssh.port}}"/>**
<log id="htpasswdResp_log" message="response: ${body}"/>
**<to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host2}}:{{ssh.port}}"/>**
<log id="htpasswdResp_log2" message="response: ${body}"/> ```
I found the solution.Just add a choice for the parametre ssh.redundancy and invoque for the second time.
<when id="redundancytrue">
<simple>{{ssh.redundancy}} == "true"</simple>
<setBody id="httpd.cmd.htpasswd">
<simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
</setBody>
<to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host2}}:{{ssh.port}}"/>
</when>
</choice>```

My Archetypes-based content type can't be added

I'm developing an add-on package which introduces a few Archetypes-based content types;
these are defined in the default profile of that package.
After (re-) installing my package in the Quick-Installer, I can see my types in the types tool; but I can't add them TTW, and they are not listed in the folder_constraintypes_form. I did select them in the "Allowed content types" multiselect list of the Folder portal type.
Since I got a ValueError from FactoryTypeInformation._getFactoryMethod in an bin/instance debug session, I "developed" Products.CMFPlone (branch 2.2) and changed the TypesTool.py like so:
from pprint import pprint # ADDED
...
class FactoryTypeInformation(TypeInformation):
...
def _getFactoryMethod(self, container, check_security=1):
if not self.product or not self.factory:
raise ValueError, ('Product factory for %s was undefined' %
self.getId())
pd = container.manage_addProduct # ADDED
p = container.manage_addProduct[self.product]
self_product = self.product # ADDED
self_factory = self.factory # ADDED
m = getattr(p, self.factory, None)
if m is None:
pprint(locals()) # ADDED
raise ValueError, ('Product factory for %s was invalid' %
self.getId())
if not check_security:
return m
if getSecurityManager().validate(p, p, self.factory, m):
return m
raise AccessControl_Unauthorized( 'Cannot create %s' % self.getId() )
The debug session now looks like this:
>>> root = app.plone
>>> from Products.CMFCore.utils import getToolByName
>>> tmp_folder = root.temp
>>> type_name = 'MyType'
>>> types_tool = getToolByName(tmp_folder, 'portal_types')
>>> type_info = types_tool.getTypeInfo(type_name)
>>> type_info
<DynamicViewTypeInformation at /plone/portal_types/MyType>
>>> new_content_item = type_info._constructInstance(tmp_folder, 'shiny_new_object')
{'check_security': 0,
'container': <ATFolder at /plone/temp>,
'pd': <App.FactoryDispatcher.ProductDispatcher object at 0x227afd0>,
'p': <App.FactoryDispatcher.FactoryDispatcher object at 0x7b97450>,
'self': <DynamicViewTypeInformation at /plone/portal_types/MyType>,
'm': None,
'self_factory': 'addMyType',
'self_product': 'MyCompany.MyProduct'}
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/zope/instances/zope-devel/src/Products.CMFCore/Products/CMFCore/TypesTool.py", line 551, in _constructInstance
m = self._getFactoryMethod(container, check_security=0)
File "/opt/zope/instances/zope-devel/src/Products.CMFCore/Products/CMFCore/TypesTool.py", line 467, in _getFactoryMethod
self.getId())
ValueError: Product factory for MyType was invalid
So, the FactoryDispatcher lacks the necessary addMyType attribute.
Probably my declarations are incomplete?
This is what I have:
config.py:
# -*- coding: utf-8 -*-
from Products.CMFCore.permissions import setDefaultRoles
from os import sep
from .permissions import (AddMyType,
)
PROJECTNAME = "MyCompany.MyProduct"
PRODUCT_HOME = sep.join(__file__.split(sep)[:-1])
MANAGERS_ONLY = ('Manager',)
MANAGERS_AND_OWNER = ('Manager', 'Owner')
# Permissions
DEFAULT_ADD_CONTENT_PERMISSION = "Add portal content"
setDefaultRoles(DEFAULT_ADD_CONTENT_PERMISSION, MANAGERS_AND_OWNER)
ADD_CONTENT_PERMISSIONS = {
'MyType': AddMyType,
}
for perm in ADD_CONTENT_PERMISSIONS.values():
setDefaultRoles(perm, MANAGERS_ONLY)
content/mytype.py:
# -*- coding: utf-8 -*-
__author__ = """unknown <unknown>"""
__docformat__ = 'plaintext'
from AccessControl import ClassSecurityInfo
from zope.interface import implements
from ..interfaces import IMyType
from ..config import PROJECTNAME
from Products.ATContentTypes.content.base import ATCTContent
from Products.ATContentTypes.content.schemata import ATContentTypeSchema
from Products.ATContentTypes.content.base import registerATCT as registerType
MyType_schema = (
ATContentTypeSchema.copy()
)
class MyType(ATCTContent):
"""
description of my type
"""
security = ClassSecurityInfo()
implements(IMyType)
meta_type = 'MyType'
_at_rename_after_creation = True
schema = MyType_schema
registerType(MyType, PROJECTNAME)
interfaces.py:
# -*- coding: utf-8 -*-
"""Module where all interfaces, events and exceptions live."""
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.interface import Interface
class ISupBetonqualiLayer(IDefaultBrowserLayer):
"""Marker interface that defines a browser layer."""
class IMyType(Interface):
"""Marker interface for .mytype.MyType
"""
permissions.py:
# -*- coding: utf-8 -*- vim: ts=8 sts=4 sw=4 si et tw=79
"""
Permissions
"""
AddMyType = 'MyCompany.MyProduct: Add MyType'
profiles/default/factorytool.xml:
<?xml version="1.0"?>
<object name="portal_factory" meta_type="Plone Factory Tool">
<factorytypes>
<type portal_type="MyType"/>
</factorytypes>
</object>
profiles/default/rolemap.xml:
<?xml version="1.0"?>
<rolemap>
<roles>
<role name="MyAuthor"/>
</roles>
<permissions>
<permission name="MyCompany.MyProduct: Add MyType" acquire="True">
<role name="MyAuthor"/>
<role name="Manager"/>
</permission>
</permissions>
</rolemap>
profiles/default/types.xml:
<?xml version="1.0"?>
<object name="portal_types"
meta_type="Plone Types Tool">
<object name="MyType"
meta_type="Factory-based Type Information with dynamic views"/>
</object>
profiles/default/types/MyType.xml:
<?xml version="1.0"?>
<object name="MyType"
meta_type="Factory-based Type Information with dynamic views"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title">MyType</property>
<property name="description">
Some description text which is indeed visible in the types tool
</property>
<property name="content_icon">SomeExisting.png</property>
<property name="content_meta_type">MyType</property>
<property name="product">MyCompany.MyProduct</property>
<property name="factory">addMyType</property>
<property name="immediate_view">mytype_view</property>
<property name="global_allow">True</property>
<property name="filter_content_types">False</property>
<property name="allowed_content_types">
</property>
<property name="allow_discussion">False</property>
<property name="default_view">mytype_view</property>
<property name="view_methods">
<element value="base_view"/>
</property>
<property name="default_view_fallback">False</property>
<alias from="(Default)" to="(dynamic view)"/>
<alias from="index.html" to="(dynamic view)"/>
<alias from="view" to="(selected layout)"/>
<alias from="edit" to="base_edit"/>
<alias from="properties" to="base_metadata"/>
<action title="View"
action_id="view"
category="object"
condition_expr=""
url_expr="string:${object_url}/view"
visible="True">
<permission value="View"/>
</action>
<action title="Edit"
action_id="edit"
category="object"
condition_expr="not:object/##plone_lock_info/is_locked_for_current_user"
url_expr="string:${object_url}/edit"
visible="True">
<permission value="Modify portal content"/>
</action>
</object>
Should not Archetypes take care of creating that missing addMyType method?
What could make this fail?
Is there something obviously missing in my configuration?
The site contains Archtypes-based objects exclusively so far. Will I come into trouble if I add Dexterity-based types now? ''(I'm totally inexperienced with Dexterity)''
Before someone tells me to do so: I created a question in the Plone community forum already; no luck so far. If important information comes in on either page, I'll sync it.
These are the missing parts to make your contenttype addable:
1.) Register the content-directory in MyCompany/MyProduct/configure.zcml by adding:
<include package=".content" />
2.) Add the file MyCompany/MyProduct/content/configure.zcml with this content:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
i18n_domain="MyCompany.MyProduct">
<class class=".mytype.MyType">
<require
permission="zope2.View"
interface="..interfaces.IMyType"
/>
</class>
</configure>
3.) Fix the then occurring syntax-error in MyCompany/MyProduct/content/mytype.py by replacing class MyType(*basecls) with class MyType(ATCTContent).
And last but not least remove the former attempts of making things work. Best would be to outsource the type to a dedicated pckg and create it with zopeskel, imo.
For the view-error occurring after adding a type, feel free to open a new quest ;-)

Javascript Bundle Definition in Plone 5

I have define my Resource Directory in configure.zcml:
<plone:static
type="plone"
name="stuff.dropdownmenu"
directory="static" />
I have define my JS Resource in registry.xml:
<records
prefix="plone.resources/stuff"
interface='Products.CMFPlone.interfaces.IResourceRegistry'>
<value key="js">++plone++stuff.dropdownmenu/stuff.js</value>
</records>
My Question: What is the right value of the Element-Tag in the Bundle Definition:
<records
prefix="plone.bundles/stuffdropdown"
interface='Products.CMFPlone.interfaces.IBundleRegistry'>
<value key="resources" purge="false">
<element>???<element>
</value>
<value key="enabled">True</value>
</records>
Is it the stuff part of prefix-Attribute or ++plone++stuff.dropdownmenu/stuff.js ?
best regards
I found in CMFPlone registry.xml that the part of prefix is the right option. The Resource Definition is here in the same file: CMFPlone registry.xml

quartz scheduling in spring 3 with batch file

i have a batch(backup.bat)file.in that i have written a command to create a backup of database
which is
<
set path=%path%;C:\Program files\MySQL\MySQL Server 5.1\bin;
mysqldump -u `root` -padmin -B jewellery > backup\jewellery.sql
exit
>
i have created a controller to call this batch file.
that is given below
<
public class JobScheduleController extends QuartzJobBean {
protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
// check FTP
try {
Runtime rt = Runtime.getRuntime();
rt.exec("cmd.exe /c start Backup.bat");
.....
.....
......
catch(Exception ex){
ex.printStackTrace();
}
}
}
>
even i have given the mapping in bean.xml that is given below
!-- Start Job Schedule for Application Backup Controllers-->
<bean name="jobScheduleController" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.jewellery.web.JobScheduleController" />
</bean>
<bean id="cronjobScheduleController" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobScheduleController" />
<!-- run at 11 am (0 0 11 ? * *") (Seconds,Minutes,Hours,Day-of-Month,Month,Day-of-Week) -->
<property name="cronExpression" value="0 0 11 ? * *" />
</bean>
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronjobScheduleController" />
</list>
</property>
</bean>
the problem is as per the given time the controller shuld search and invoke the batch file to execute.but it says the batch file not found.
where shuld i place the batch file .
the same code was running succussfully in spring 2.0,nw i have migrated to spring 3.
where shuld i place my batch file.?
i am using eclipse indigo...?and one more thing is this the best way to do it or some other way is also there..if there kindly let me knw.
Just set Backup.bat in your environment path variable

Resources