How to use Custom Action for Condition? - service

I need to check if some service already installed in system before continue installation.
I.e. I have added
<Condition Message="Svc must be installed">
Installed OR SVC_V1
</Condition>
But I can check if it is installed only by using Custom Action because Svc is Windows Service. How I can use CA for this condition?

Custom Actions set properties that then can be used to evaluate a condition.

Actually you don't need custom action for detecting your service. Services get registered under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ so you can use RegistrySearch:
<Property Id="SVC_V1">
<RegistrySearch Id='RegSampleService'
Type='raw'
Root='HKLM'
Name='ImagePath'
Key="SYSTEM\CurrentControlSet\services\YourService" />
</Property>
Note however that Registry read permissions are required.

Related

(Keycloak) Freemarker Template system properties and environment variables

We wanted to work on the Templates and tried to get the system properties that we set earlier in the standalone.xml file like this.
</extensions>
<system-properties>
<property name="testProp" value="TestVal"/>
</system-properties>
In the Docs of Keycloak its described like the following.
${some.system.property} - for system properties
${env.ENV_VAR} - for environment variables.
But nothing worked for us. We always get the following error Message “An internal server error has occurred”.
What is the right way to get the system properties and the environment variables in the Freemarker Template?
Keycloak Theme Property Documentation
is missing how to add them in the template.
It is however just a bit lower in the same document
So in theme.properties could be
customPropInThemeProperties=${env.SOME_OTHER_RESOURCE_URL}
Then uses in .ftl as
${properties.customPropInThemeProperties}
In order to use system properties in the freemarker template of keycloak, do the following configuration.
Declare your system properties in the standalone.xml
<system-properties>
<property name="UATLogin" value="http://localhost:9090" />
</system-properties>
Add variable inside theme.properties to access the system property.
UATURL=${UATLogin}
As an example, I have done the testing with register.ftl
<span>${kcSanitize(msg("backToLogin"))?no_esc}</span>

Quartz trigger state is not persisting on server start

We have a requirement to pause a job before application maintenance. We are using Quartz 2.2.1 in cluster. Database is oracle.
I have developed a screen with "Pause" functionality. I observed that "pause" works fine until I start the server again. The moment I start server, TRIGGER_STATE of QRTZ_TRIGGERS table resets to "WAITING".
Can anyone please provide a hint.
Thanks a lot in advance.
Rgds - Roy
If you have set overwriteExistingJobs=true (note that default value is false) then each time server starts, it loads the jobs/triggers from the configuration file and replaces existing ones (that have the same job/trigger names), therefore overwriting triggers and their states too as in your case.
You could try to set overwriteExistingJobs=false in the SchedulerFactoryBean. This however may not be convenient for you, since if you ever change job configuration in the server, the existing jobs with old configuration will remain in the database.
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
....
<property name="overwriteExistingJobs" value="false"/>
<property name="triggers">
<list>
....
</list>
</property>
....
</bean>

Report job scheduling with custom data-source in jasper server 4.5.0

I am using Jasperserver 4.5.0 Pro. I have developed a custom data-source for some additional feature. All reports that use this custom DS get executed properly and show the correct output when executed manually. But when the same reports are scheduled using Jasper's report job scheduler, there is some problem with session initiation, and hence the reports do not get executed.
Let me explain this a bit.
For manual execution of reports -
As part of custom DS, I had to update the following 2 xmls -
viewReportFlow.xml :
I updated the action state 'runReport' to use our custom DS executer action bean method 'xmlHttpDsExecuterAction.setUpSession' to start session. Please see the below tag of runReport -
<action-state id="runReport" xmlns:b="http://www.springframework.org/schema/webflow" xmlns:xi="http://www.w3.org/2001/XInclude">
<on-entry>
<evaluate expression="xmlHttpDsExecuterAction.setUpSession"/>
</on-entry>
<evaluate expression="viewReportActionBean"/>
<transition on="success" to="reportOutput"/>
<on-exit>
<evaluate expression="xmlHttpDsExecuterPageAction.setIndex"/>
</on-exit>
viewReportBeans.xml :
I defined the executer action beans used in above flow xml here -
<bean id="xmlHttpDsExecuterAction" class="com.sigma.reporting.xmlhttpds.XmlHttpDsExecuterAction" xmlns:xsi="http://www.w 3.org/2001/XMLSchema-instance"/> <bean id="xmlHttpDsExecuterPageAction" class="com.sigma.reporting.xmlhttpds.XmlHttpDsExecuterPageAction" xmlns:xsi="http://www.w 3.org/2001/XMLSchema-instance">
<property name="requestParameterPageIndex" value="pageIndex"/>
<property name="flowAttributePageIndex" value="pageIndex"/>
<property name="xmlHttpDataSourceName" value="com.sigma.reporting.xmlhttpds.XmlHttpDsExecuterDataSourceService"/>
<property name="repository">
<ref bean="repositoryService"/>
</property>
<property name="jasperPrintName" value="jasperPrintName"/>
<property name="reportUnitObject" value="reportUnitObject"/> </bean>
For job scheduling of reports :
I want to implement similarly as above using scheduler. During my investigations, I have tried to analyze the scheduler flow, and tried to put our changes, but no luck so far. Can any one please let me know what flows are used for running reports via scheduler and also please recommend the places to configure custom DS as above?
Finally after understanding the flow of japser server scheduler i have got the solution for this.
For setting your custom data source beans and calling the function,we need to specify the bean destination in $JASPER_HOME/apache-tomcat/weaaps/jasperserver-pro/WEBINF/flows/reportJobBeans.xml and we can use this bean in reportJobFlow.xml in jobOutput tag lik this
<view-state id="jobOutput" view="modules/reportScheduling/jobOutput">
<on-entry>
<set name="flowScope.prevForm" value="'jobOutput'"/>
<evaluate expression="reportOptionsJobEditAction.setOutputReferenceData"/>
<evaluate expression="xmlHttpDsExecuterAction.setUpSession"/>
</on-entry>
</view-state>

Control Scheduling in JasperReports Server

I want to prevent normal users from scheduling a report.
Only administrator will have the right to schedule report.
Is it possible with JasperReports Server?
Yes, it is possible.
You should edit the jasperserver\WEB-INF\actionModel-search.xml file.
You need to find the definition of ScheduleAction action in this file and add the condition for the ROLE_ADMINISTRATOR role:
<context name="resource_menu">
<simpleAction labelKey="RM_BUTTON_RUN" action="invokeRedirectAction" actionArgs="RunResourceAction"
clientTest="canBeRun" className="up"/>
<condition test="isSupportedDevice">
<simpleAction labelKey="RM_BUTTON_RUN_IN_BACKGROUND" action="invokeRedirectAction" actionArgs="RunInBackgroundResourceAction"
clientTest="canBeRunInBackground" className="up"/>
<condition test="checkAuthenticationRoles" testArgs="ROLE_ADMINISTRATOR">
<simpleAction labelKey="RM_BUTTON_SCHEDULE_REPORT" action="invokeRedirectAction" actionArgs="ScheduleAction"
clientTest="canBeScheduled" className="up"/>
</condition>
<simpleAction labelKey="RM_BUTTON_WIZARD" action="invokeRedirectAction" actionArgs="EditResourceAction"
clientTest="canResourceBeEdited" className="up"/>
</condition>
I've just add the <condition test="checkAuthenticationRoles" testArgs="ROLE_ADMINISTRATOR"> for the ScheduleAction action.
After that you should restart the application server (Tomcat).

Replace web config *elements* with msdeploy parameters

We're using msdeploy (or web deploy if you wish) to package and deploy web apps. By declaring parameters package time we can provide values at deploy time (to replace connection strings among other things).
The problem we currently face is replacing values in applicationSettings sections in our web config. We can't get msdeploy to replace the value because the content we want to replace is the text inside an xml element, not an attribute value (the warning we get is: "Cannot set a value on node type 'Element'").
The relevant config looks like this:
<applicationSettings>
<Name.Of.Assembly.Properties.Settings>
<setting name="someSetting" serializeAs="String">
<value>I wanna be replaced</value>
</setting>
</Name.Of.Assembly.Properties.Settings>
</applicationSettings>
and the declare parameter xml looks like this:
<parameter name="XX" defaultValue="default">
<parameterEntry kind="XmlFile"
scope="Web\.config$"
match="/configuration/applicationSettings/Name.Of.Assembly.Properties.Settings/setting[#name='someSetting']/value" />
</parameter>
Does msdeploy only support replacing attribute values or am I doing something wrong?
For posterity...
You just need to add "/text()" to the end of the match. That will change the value of enclosed by the tags. However, this value cannot be empty in the source web.config. So when you build the deployment package using the "Release" solution configuration, the web.Release.config must not set this value of the setting to an empty value.
<parameter name="XX" defaultValue="default">
<parameterEntry kind="XmlFile"
scope="Web\.config$"
match="/configuration/applicationSettings/Name.Of.Assembly.Properties.Settings/setting[#name='someSetting']/value/text()" />
</parameter>