-
Notifications
You must be signed in to change notification settings - Fork 17
Installing into Tomcat
NOTE: This primarily concerns people with access to the CWMS database, unfortunately due to some other licensing issues (the JOOQ code gen) that's somewhat tricky, however we will likely split that portion out to provide access to the database itself for others to chomp on. For now this assumes you already have a database available.
WAR name | Purpose |
---|---|
cwms-data.war | For our central system and some testing. The logic in ApiServlet.java will configure itself for access to all data. |
<district> -data.war |
where <district> is replaced with something like spk, swt, nwdm, etc |
It assumes there is a JNDI resource available called jdbc/CWMS3, and that the account presented has appropriate permissions for the office at hand. One of the above or "HQ" in the case of cwms-data.
- Download the war from the releases
- Rename the war to
<DISTRICT>-data.war
(i.e.swf-data.war
, this is important to keep it consistent across enterprise) - Using an SFTP client (WinSCP) copy the war to this directory
/wm/DISTRICT/wm_web/deploy_war
on your T7. - Open a putty/SSH client and navigate to the deploy directory with
cd /wm/DISTRICT/wm_web/deploy_war
- In the terminal run
./deploy_war.sh <district>-data.war
- Wait 5-10 minutes
- Navigate to your internal T7 cwms instance it would be something like
https://hostname:tomcatport/<DISTRICT>-data
- You should see a swagger page like this national public page, only, it's your internal instance!
- Create a script in
/wm/<district>/wm_web/deploy_war
calledupdate_cda.sh
- Give the script execute permissions as the cwp user with
chmod +x /wm/<district>/wm_web/deploy_war/update_cda.sh
- Paste the following into the script and save
#!/bin/bash
# Must be ran from /wm/<district>/wm_web/deploy_war/
REPO_API_URL="https://api.github.com/repos/USACE/cwms-data-api/releases/latest"
DEPLOY_SCRIPT="./deploy_war.sh"
directory_name=$(echo "$(pwd)" | awk -F'/' '{print $3}')
war_file_name="${directory_name}-data.war"
temp_war_file="temp_release.war"
echo "Fetching latest release information..."
war_download_url=$(curl -s "$REPO_API_URL" | grep -i "browser_download_url" | sed -n 's/.*"browser_download_url": "\(.*\)".*/\1/p')
# Check if the .war file URL was found
if [[ -z $war_download_url ]]; then
echo "Error: Could not find the .war file in the latest release."
exit 1
fi
echo "Downloading .war file from: $war_download_url"
wget -O "$temp_war_file" "$war_download_url"
mv "$temp_war_file" "$war_file_name"
echo "Renamed .war file to $war_file_name"
if [[ -x $DEPLOY_SCRIPT ]]; then
echo "Executing deployment script..."
$DEPLOY_SCRIPT "$war_file_name"
else
echo "Error: Deployment script $DEPLOY_SCRIPT is not executable."
exit 1
fi
- Run the script with
./update_cda.sh
- Navigate to your internal CDA swagger page and confirm the version has updated. A gray box at the very top of the screen shows the version.
That's it!
- If you would like to learn some quick tips here is a 10 minute video on how to use the Swagger UI.
- There are no CORS headers set
- if you don't have Tomcat itself or another fronting proxy you can add the appropriate config to the WEB-INF/web.xml inside the .war file. Don't extract, just open in 7ZIP.
- If you are NWO, this would be
nwdm-data.war
The minimum you need for CORS support is the following, but it's highly recommended to change the asterisk (*) to a comma-delimited list of the appropriate origins your site requires.
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>
For systems with write access you will also need the CAC auth module and several configuration changes. Contact HEC.