Deployment automation script XML file handling

November 20, 2017 at 04:22:47
Specs: Windows 7
I'm doing a deployment automation, after deploying the packages now there are lot of manual changes are happen in xml and in some property files. For that changes developers will provide us the instruction in a text file as which file and in which path its located and what's the change. Say for example I've some web.xml file. below is my sample xml file Same like I'll have lot of configuration changes.

My Sample web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee " target="_blank">http://java.sun.com/xml/ns/javaee/w...
<display-name>Struts2 Application</display-name>

<error-page>
<error-code>404</error-code>
<location>/ErrorPage.jsp</location>

</error-page>

<error-page>
<error-code>403</error-code>
<location>/ErrorPage.jsp</location>

</error-page>
<error-page>
<error-code>500</error-code>
<location>/ErrorPage.jsp</location>

</error-page>

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/ErrorPage.jsp</location>
</error-page>

<listener>
<listener-class>com.SessionListener</listener-class>
</listener>


<!-- Commenting as per discussion -->

<!--
<filter>
<display-name>CompressionFilter</display-name>
<filter-name>CompressionFilter</filter-name>
<filter-class>com.CompressionFilter</filter-class>

<init-param>
<param-name>excludeURI</param-name>
<param-value>documentDownloadIFADD,</param-value>
</init-param>

</filter>
<filter-mapping>
<filter-name>CompressionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->


<!-- WI Auth filter changes by Tuhin -->

<filter>
<display-name>WIAuthFilter</display-name>
<filter-name>WIAuthFilter</filter-name>
<filter-class>com.WIAuthFilter</filter-class>
<init-param>
<param-name>userHeader</param-name>
<param-value>OAM_REMOTE_USER</param-value>
</init-param>
<init-param>
<param-name>excludeParam</param-name>
<param-value>filterCriteria,svgDataForPublishPlan,svgChart,hiddeninvstmntvalue,idHidden2,bankName,clientLabelData,monitoredJson,pageTitleLbl,hiddenVariable3,tableThruResponseMonitored,ToolTip,ReasonsDropBox,confirmSvgData,currencyCombo_Tooltip,cancelInsDescrip,bankingDetailTable_RowValue,editInsDescrip,OneOffEditLink_Title,riskLevelTable,svgDataForReportPlan,paginationData,tableThruResponseLive,tableApplicationPytMthdOne_RowValue,savingsTable_RowValue,lumpsumContributionTableOne_RowValue,paymentTable_RowValue,premiumTable_RowValue,confirmationOfChargesTable_RowValue,fundadviserTable1_RowValue,livesassuredTable_RowValue,lumpsumOriginofwealthTable_RowValue,collectiveSector,transactionData,onBackFlag,hiddenPagination
,filterEdit,filtersArrayVal,Filters,chkBoxArrayVal,warningTxtD,warningTxtR,filtersFromCurrent,AssetClassCombo,SectorCombo,RegularWithdrawalJSON,RWJosn,hiddenVariable6,tableThruAjax,documentName</param-value>
</init-param>
<init-param>
<param-name>loginURI</param-name>
<param-value>/login</param-value>
</init-param>
<init-param>
<param-name>realexURI</param-name>
<param-value>/RealexServlet.srl</param-value>
</init-param>
<init-param>
<param-name>logoutURI</param-name>
<param-value>/logout.action</param-value>
</init-param>
<!-- downloadURI
To download static content we should use below path, do not add any other url in this param
-->
<init-param>
<param-name>downloadURI</param-name>
<param-value>/_static_contents_/download</param-value>
</init-param>
<init-param>
<param-name>AuthMode</param-name>
<!-- Modes:
SnROnly - default, only SnR URL will be allowed,
SnRWithBypass- login bypass will be allowd (onsite test),
NoSnR - No SnR, filter will be disabled (Offshore Only)
-->
<!-- To use SnROnly/ SnRWithBypass we need to make sure
1: jaas config
BFS{
com.BFSSiteMinderLoginModule required debug=true;
};

2:MCSystem.prop
singleSignon=yes

3:DB script change
In security_parameter table entry singlesignon=3 for systemid 2(extranet)

-->
<param-value>SnRWithBypass</param-value>
</init-param>
<init-param>
<param-name>logfile</param-name>
<param-value>E:\Product\logs\wiauth.log;10M</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>WIAuthFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<display-name>StaticContentFilter</display-name>
<filter-name>StaticContentFilter</filter-name>
<filter-class>com.StaticContentFilter</filter-class>

<!--
* Parameter Name: staticContextRoot -> the sub context root for static context in the formed virtual path
* Mandatory
* Fingerprint (MD5 hash of the file) will follow this sub context root
-->
<init-param>
<param-name>staticContextRoot</param-name>
<param-value>_static_contents_</param-value>
</init-param>

<!--
* Parameter Name: contentTypes -> the comma separate list content type considered for URI replacement in the response body
* Mandatory
-->
<init-param>
<param-name>contentTypes</param-name>
<param-value>text/html,text/css,application/javascript,text/plain</param-value>
</init-param>

<!--

* Parameter Name: CacheExpiryInSeconds -> no of seconds after which cache will expire in browser

* Optional

* Default Value = 31536000 (1 Year)

-->

<init-param>

<param-name >CacheExpiryInSeconds </param-name>

<param-value> 31536000 </param-value>

</init-param>

<!--

* Parameter Name: staticContentExtensions

* Optional

* Default Value = .css,.html,.htm,.pdf,.jpg,.jpeg,.png,.gif,.js

* Comma seperated list of extension for which the URI replacement will be done


-->
<init-param>

<param-name>staticContentExtensions</param-name>

<param-value>.css,.html,.htm,.pdf,.jpg,.jpeg,.pjpeg,.png,.gif,.js</param-value>

</init-param>

<!--
* Parameter Name: maxFileSizeToReplace -> Size in bytes or in KB (K) or MB (M)
* Optional
* Default Value = 512M
* This controls the static file replacement - if any static file is more than specified size,
* that will not be considered for URI replacement inside the file 9to avoid too much memory consumption)

<init-param>
<param-name>maxFileSizeToReplace</param-name>
<param-value>512M</param-value>
</init-param>
-->
<!--
* Parameter Name: ignoreURIs -> the comma separate list of URIs (exlusive of context root path), which will be ignored for URI replacement inside
* Optional
* Default Value = Blank list
* The URIs mentioned will be skipped URI replacements

<init-param>
<param-name>ignoreURIs</param-name>
<param-value>/path1,/path2</param-value>
</init-param>
-->
<init-param>
<param-name>ignoreURIs</param-name>
<param-value>/realexNvgtn</param-value>
</init-param>
<!--
* Parameter Name: listNonReplacableURIs -> the comma separate list of URIs (exlusive of context root path), which will not be replaced
* Optional
* Default Value = Blank list
* The URIs mentioned will be not be replaced if used in response as script, CSS or image inclusion
-->
<init-param>
<param-name>listNonReplacableURIs</param-name>
<param-value>/alfresco.srl</param-value>
</init-param>

<!--
* Parameter Name: logfile -> logfile name and size
* Format : <Logfile path>;Size -> logfile path could be a directory or full path including file name, size could be in bytes, KB (K) or MB (M)
* Ex : /usr/log/abc.log;10M
* Optional
* Default Value = if nothing specified, logging will be off. If size is not specified or invalidly specified default will be 5MB
* If file is specified and writable then log will be written in that path.
* If the path is directory the "staticfilter.log" file will be created under the path.
* Log will be rotated after the size reached the size mentioned (default 5MB)
-->
<init-param>
<param-name>logfile</param-name>
<param-value>E:\Product\staticfilter.log;10M</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>StaticContentFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<!-- CSRF Vulnerability -->
<filter>
<filter-name>CSRFShield</filter-name>
<filter-class>com.CSRFShieldFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/csrfguard.properties</param-value>
</init-param>
</filter>


<filter-mapping>
<filter-name>CSRFShield</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- CSRF Vulnerability -->

<!--<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<servlet>
<servlet-name>WMPInitServlet</servlet-name>
<servlet-class>com.WMPInitServlet</servlet-class>

<load-on-startup>2</load-on-startup>
</servlet>-->

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>WMPInitServlet</servlet-name>
<servlet-class>com.WMPInitServlet</servlet-class>

<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<description>
</description>
<servlet-name>RealexServlet</servlet-name>
<servlet-class>
com.RealexServlet</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>RealexServlet</servlet-name>
<url-pattern>/RealexServlet.srl</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>alfresco</servlet-name>
<servlet-class>com.HttpProxyServlet</servlet-class>
<init-param>
<param-name>log</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>alfresco</servlet-name>
<url-pattern>/alfresco.srl/*</url-pattern>
</servlet-mapping>


<servlet>
<description>
</description>
<display-name>
AplStartup</display-name>
<servlet-name>AplStartup</servlet-name>
<servlet-class>
iims.workflow.util.AplStartup</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>AplStartup</servlet-name>
<url-pattern>/AplStartup</url-pattern>
</servlet-mapping>

<servlet>
<description>
</description>
<display-name>
DMSStartup</display-name>
<servlet-name>DMSStartup</servlet-name>
<servlet-class>
dms.DMSStartup</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>DMSStartup</servlet-name>
<url-pattern>/DMSStartup</url-pattern>
</servlet-mapping>

<servlet>
<description>
</description>
<display-name>
IIMSStartup</display-name>
<servlet-name>IIMSStartup</servlet-name>
<servlet-class>
iimsStartup.IIMSStartup</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>IIMSStartup</servlet-name>
<url-pattern>/IIMSStartup</url-pattern>
</servlet-mapping>
<servlet>
<description>
</description>
<display-name>
IIMSStartupNext</display-name>
<servlet-name>IIMSStartupNext</servlet-name>
<servlet-class>
iimsStartup.IIMSStartupNext</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>IIMSStartupNext</servlet-name>
<url-pattern>/IIMSStartupNext</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>TreeServlet</servlet-name>
<servlet-class>iimsStartup.TreeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TreeServlet</servlet-name>
<url-pattern>/TreeServlet</url-pattern>
</servlet-mapping>

<session-config>
<session-timeout>30</session-timeout>
</session-config>

<mime-mapping>
<extension>doc</extension>
<mime-type>application/doc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>csv</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>

<mime-mapping>
<extension>js</extension>
<mime-type>application/javascript</mime-type>
</mime-mapping>

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

<welcome-file-list>
<welcome-file>LoginSR.jsp</welcome-file>
</welcome-file-list>


<jsp-config>
<taglib>
<taglib-uri>/tags/ebw-taglibs</taglib-uri>
<taglib-location>/WEB-INF/ebwtaglibs.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/CSRFGuard-taglibs</taglib-uri>
<taglib-location>/WEB-INF/CSRFGuard.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/c</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/wcm</taglib-uri>
<taglib-location>/WEB-INF/WCM.tld</taglib-location>
</taglib>

</jsp-config>

</web-app>

In this above xml I've check the value if it's available SnRWithBypass if not need to append the value.

<init-param>
<param-name>AuthMode</param-name>
**<param-value>SnRWithBypass</param-value>**
</init-param>

<init-param>

Same like above I want to check the value welcome-file as LoginSR.jsp if not change it to LoginSR.jsp

<welcome-file-list>
<welcome-file>LoginSR.jsp</welcome-file>
</welcome-file-list>
Like wise I have 20 number of xml and property files changes right now. Is it possible to achieve this manual works to automate. Could anyone please guide me to achieve this.


See More: Deployment automation script XML file handling

Reply ↓  Report •

#1
November 20, 2017 at 07:22:37
Not sure why you can't just make your desired XML with all of the required changes, and just have your deployment script replace the existing XML.

How To Ask Questions The Smart Way


Reply ↓  Report •
Related Solutions


Ask Question