Issue #1762: Remove NATIONAL_CENTER setting from svcbu.properties,

all code that used that setting will now use new
CheckServiceBackupPrimarySiteRequest.

Change-Id: I0f9ebe68ba73a6aaf1882ae361327d7681449e31

Former-commit-id: 1b2c23abda7ed0a296bf1ffb1f3e8e27dc02555e
This commit is contained in:
David Gillingham 2013-05-01 17:05:20 -05:00
parent d66d7b5968
commit 0259bb6672
9 changed files with 326 additions and 147 deletions

View file

@ -21,18 +21,16 @@ package com.raytheon.viz.gfe.dialogs.sbu;
import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.request.CheckPermissionsRequest; import com.raytheon.uf.common.dataplugin.gfe.request.CheckPermissionsRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest; import com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.site.requests.GetPrimarySiteRequest;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.auth.UserController; import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.core.requests.ThriftClient;
/** /**
* TODO Add Description * A utility class for the Service Backup GUI to do permissions checks.
* *
* <pre> * <pre>
* *
@ -42,6 +40,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Aug 11, 2011 bphillip Initial creation * Aug 11, 2011 bphillip Initial creation
* Nov 14, 2012 jdynina Added check for national center * Nov 14, 2012 jdynina Added check for national center
* May 02, 2013 #1762 dgilling Replace national center check with
* a svcbu PRIMARY_SITES check.
* *
* </pre> * </pre>
* *
@ -54,6 +54,16 @@ public class CheckPermissions {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ServiceBackupDlg.class); .getHandler(ServiceBackupDlg.class);
/**
* A private constructor so that Java does not attempt to create one for us.
* As this class should not be instantiated, do not attempt to ever call
* this constructor; it will simply throw an AssertionError.
*
*/
private CheckPermissions() {
throw new AssertionError();
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static boolean getAuthorization() { public static boolean getAuthorization() {
boolean authorized = false; boolean authorized = false;
@ -75,38 +85,17 @@ public class CheckPermissions {
return authorized; return authorized;
} }
@SuppressWarnings("unchecked")
public static boolean isNationalCenter() {
boolean isNationalCenter = false;
NcCheckRequest request = new NcCheckRequest();
try {
ServerResponse<String> obj = (ServerResponse<String>) ThriftClient
.sendRequest(request);
if (obj.isOkay()) {
isNationalCenter = true;
} else {
isNationalCenter = false;
}
} catch (VizException e) {
statusHandler.error("Error checking site type!", e);
isNationalCenter = false;
}
return isNationalCenter;
}
public static boolean runningAsPrimary() { public static boolean runningAsPrimary() {
boolean isPrimary = false; CheckServiceBackupPrimarySiteRequest request = new CheckServiceBackupPrimarySiteRequest();
GetPrimarySiteRequest request = new GetPrimarySiteRequest();
try { try {
String obj = (String)ThriftClient @SuppressWarnings("unchecked")
ServerResponse<Boolean> sr = (ServerResponse<Boolean>) ThriftClient
.sendRequest(request); .sendRequest(request);
return LocalizationManager.getInstance().getCurrentSite() return sr.getPayload();
.equalsIgnoreCase(obj);
} catch (VizException e) { } catch (VizException e) {
statusHandler statusHandler
.error("Error checking if running as primary site!", e); .error("Error checking if running as primary site!", e);
} }
return isPrimary; return false;
} }
} }

View file

@ -92,6 +92,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* Nov 15, 2012 15614 jdynina Added check for national center * Nov 15, 2012 15614 jdynina Added check for national center
* Mar 20, 2013 1447 dgilling Port troubleshooting mode changes * Mar 20, 2013 1447 dgilling Port troubleshooting mode changes
* from A1 DR 21404, some code cleanup. * from A1 DR 21404, some code cleanup.
* May 01, 2013 1762 dgilling Remove national center check.
* *
* </pre> * </pre>
* *
@ -158,8 +159,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
private boolean authorized; private boolean authorized;
private boolean nationalCenter;
private SVCBU_OP currentOperation = SVCBU_OP.no_backup; private SVCBU_OP currentOperation = SVCBU_OP.no_backup;
/** /**
@ -169,7 +168,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
super(parentShell); super(parentShell);
authorized = CheckPermissions.getAuthorization(); authorized = CheckPermissions.getAuthorization();
this.site = LocalizationManager.getInstance().getCurrentSite(); this.site = LocalizationManager.getInstance().getCurrentSite();
this.nationalCenter = CheckPermissions.isNationalCenter();
this.runningAsPrimary = CheckPermissions.runningAsPrimary(); this.runningAsPrimary = CheckPermissions.runningAsPrimary();
if (!ServiceBackupJobManager.getInstance().isRunning()) { if (!ServiceBackupJobManager.getInstance().isRunning()) {
ServiceBackupJobManager.getInstance().start(); ServiceBackupJobManager.getInstance().start();
@ -1194,7 +1192,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
+ UserController.getUserObject().uniqueId()); + UserController.getUserObject().uniqueId());
} }
if ((!runningAsPrimary) & (!nationalCenter)) { if (!runningAsPrimary) {
doExCon.setEnabled(false); doExCon.setEnabled(false);
} }
} }

View file

@ -0,0 +1,203 @@
#!/usr/bin/env python
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
import logging
import shutil
import sys
from ufpy import ConfigFileUtil
logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%H:%M:%S",
level=logging.INFO)
SVCBU_CONFIG_FILENAME = "/awips2/GFESuite/ServiceBackup/configuration/svcbu.properties"
SVCBU_CONFIG_BACKUP_FILENAME = SVCBU_CONFIG_FILENAME + ".bak"
SVCBU_CONFIG_MIGRATE = ['SVCBU_HOST', 'MSG_SEND_COMMAND', 'CDSPORT', 'SVCBU_DB',
'SVCBU_TRIM_ELEMS', 'SVCBU_FAILED_SITE_PORT',
'SVCBU_GRIDAREA', 'SVCBU_ADDRESSEE', 'SVCBU_WMO_HEADER',
'SVCBU_USER', 'SVCBU_USER_ID', 'EXPORT_GRID']
STATIC_CONFIG_DATA = """
#Variables used by service backup:
#
# AWIPS_HOME: The AWIPS II installation directory.
#
# GFESUITE_HOME: The server directory containing files and programs
# used by GFE during Service Backup
#
# GFESUITE_BIN: Directory containing GFE server side utility
# programs including ifpnetCDF and iscMosaic
#
# SVCBU_HOME: Directory used by service backup as a sandbox for
# constructing files to be sent and for processing
# received files.
#
# LOCALIZATION_PATH: This is the path to the root of the localization
# directory. This path is used for properly importing
# and exporting configuration data
#
# IFPS_LOG: Directory containing logs for the service backup
# operations.
#
# IFPS_DATA: Directory containing the svcbu_export_elements file.
# This file is used to specify which weather elements are
# packaged and sent when exporting digital data for a
# site.
#
# LOCK_DIR: Directory used for lock files. Each Service Backup
# operation maintains a lock file during its execution.
# The lock remains for the duration of the operation and
# is erased upon completion to prevent simultaneous
# operations from occurring.
#
# SCRIPTS_DIR: Directory containing the scripts used by service
# backup
#
# CAVE_LAUNCH_SCRIPT: This path points to the script which starts GFE. This
# variable is read when the user hits the 'Enable' button
# On the service backup GUI.
#
# SVCBU_HOST: Server where the service backup scripts will be
# executed.
#
# MSG_SEND_COMMAND: The command executed to send a message via the message handling
# system. This value will usually be msg_send. But, it can be
# changed to a different command in a test environment.
#
# CDSPORT: This is the port on which the Thrift Client listens
# for script execution events.
#
# SVCBU_DB: Defines which database to use for exporting
# grids to central server for service backup.
# VALID VALUES: Fcst
# Official (default)
#
# SVCBU_TRIM_ELEMS: Indication of whether ifpnetCDF needs to trim
# off elements while exporting grids to central
# server.
# VALID VALUES: 1 - To do element trimming
# 0 - To disable element trimming
# Note: ${IFPS_DATA}/svcbu_export_elements.ccc
# file has to be present for this to work. This file
# will contain list of elements to include in the
# netcdf file that's being sent over to central srv.
#
# SVCBU_FAILED_SITE_PORT: Unused
#
# SVCBU_GRIDAREA: The name of the edit area used when exporting grids
# to the central server for service backup and
# imported to the Restore databse after service backup.
# DEFUALT VALUE: ISC_Send_Area
#
# SVCBU_ADDRESSEE: The name of the msg_send addressee. Will be used to
# pass with -a flag of msg_send. (NCF use only).
#
# SVCBU_WMO_HEADER: The WMO header that will be used to pass in calls to
# msg_send with -i argument. This will be empty to
# begin with. Should not be changed. (NCF use only)
#
# EXPORT_GRID Indicate the ways of grid being exported
# VALID VALUES: 0 = do not export grids
# 1 = grids are exported by quartz timer
# at 15 after each hour, the service
# backup GUI, and from GFE via the
# 'Send Grids to NDFD...' script
# 2 = grids are exported only by the service backup GUI and from GFE via the 'Send
# Grids to NDFD...' script'
#
# SVCBU_USER Indicates that the site can configure a special user to
# run GFE when in service backup
# VALID VALUES: 0 = do not use a designated user to run
# GFE when in service backup
# 1 = use a designated user to run GFE
# when in service backup
#
# SVCBU_USER_ID The user id of the designated user to run GFE when
# in service backup
#
# PRIMARY_SITES (Optional) For dual-domain sites, a comma-separated
# list of sites for the export grids cron to run for
# instead of the site defined as AW_SITE_IDENTIFIER. If
# this setting is empty or not defined, cron will only
# export grids for site set as AW_SITE_IDENTIFIER.
#
#
# Directories used by Service Backup
GFESUITE_HOME=/awips2/GFESuite
GFESUITE_BIN=/awips2/GFESuite/bin
SVCBU_HOME=/awips2/GFESuite/ServiceBackup/svcbu
LOCALIZATION_PATH=/awips2/edex/data/utility
IFPS_LOG=/awips2/GFESuite/ServiceBackup/logs
IFPS_DATA=/awips2/GFESuite/ServiceBackup/data
LOCK_DIR=/awips2/GFESuite/ServiceBackup/locks
SCRIPTS_DIR=/awips2/GFESuite/ServiceBackup/scripts
CAVE_LAUNCH_SCRIPT=/awips2/cave/cave.sh
"""
def get_old_config():
return ConfigFileUtil.parseKeyValueFile(SVCBU_CONFIG_FILENAME)
def backup_old_config():
shutil.move(SVCBU_CONFIG_FILENAME, SVCBU_CONFIG_BACKUP_FILENAME)
def write_new_config(old_vals):
with open(SVCBU_CONFIG_FILENAME, 'w') as configOut:
configOut.write(STATIC_CONFIG_DATA)
for entry in SVCBU_CONFIG_MIGRATE:
oldValue = old_vals[entry]
configOut.write(entry + "=" + oldValue + "\n")
configOut.write("PRIMARY_SITES=")
if "NATIONAL_CENTER" in old_vals and old_vals["NATIONAL_CENTER"] == '1':
logging.warning("Since this system was previously configured as a " +
"national center, please configure the " +
"PRIMARY_SITES setting with your GFE sites after " +
"this script is complete.")
def main():
logging.info("Migrating svcbu.properties for 13.5.1.")
try:
oldConfig = get_old_config()
except:
logging.exception("Could not read old configuration from " + SVCBU_CONFIG_FILENAME)
try:
backup_old_config()
except:
logging.exception("Could not backup previous svcbu.properties.")
try:
write_new_config(oldConfig)
except:
logging.exception("Could not write new svcbu.properties.")
logging.info("Migration complete.")
logging.info("After you have verified that svcbu.properties was properly migrated, " +
"please delete the file " + SVCBU_CONFIG_BACKUP_FILENAME + ".")
if __name__ == '__main__':
main()

View file

@ -347,6 +347,14 @@
<constructor-arg ref="CheckPermissionsRequestHandler" /> <constructor-arg ref="CheckPermissionsRequestHandler" />
</bean> </bean>
<bean id="CheckPrimarySiteHandler"
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.CheckServiceBackupPrimarySiteHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest" />
<constructor-arg ref="CheckPrimarySiteHandler" />
</bean>
<bean id="CleanupSvcBuLogRequestHandler" <bean id="CleanupSvcBuLogRequestHandler"
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.CleanupSvcBuLogRequestHandler" /> class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.CleanupSvcBuLogRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">
@ -355,14 +363,6 @@
<constructor-arg ref="CleanupSvcBuLogRequestHandler" /> <constructor-arg ref="CleanupSvcBuLogRequestHandler" />
</bean> </bean>
<bean id="NcCheckRequestHandler"
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.NcCheckRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest" />
<constructor-arg ref="NcCheckRequestHandler" />
</bean>
<bean id="ExportConfRequestHandler" <bean id="ExportConfRequestHandler"
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportConfRequestHandler" /> class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportConfRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">

View file

@ -20,12 +20,14 @@
package com.raytheon.edex.plugin.gfe.server.handler.svcbu; package com.raytheon.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil; import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest; import com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler; import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/** /**
* TODO Add Description * Handler for <code>CheckServiceBackupPrimarySiteRequest</code>. Determines
* whether the specified site id has been configured as one of service backup's
* primary sites.
* *
* <pre> * <pre>
* *
@ -33,26 +35,31 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2012 jdynina Initial creation * May 02, 2013 dgilling Initial creation
* *
* </pre> * </pre>
* *
* @author jdynina * @author dgilling
* @version 1.0 * @version 1.0
*/ */
public class NcCheckRequestHandler implements IRequestHandler<NcCheckRequest>{ public class CheckServiceBackupPrimarySiteHandler implements
IRequestHandler<CheckServiceBackupPrimarySiteRequest> {
public Object handleRequest(NcCheckRequest request) /*
throws Exception { * (non-Javadoc)
ServerResponse<String> sr = new ServerResponse<String>(); *
if (!isNationalCenter()) { * @see
sr.addMessage("Site is not a national center."); * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
} * (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public ServerResponse<Boolean> handleRequest(
CheckServiceBackupPrimarySiteRequest request) throws Exception {
ServerResponse<Boolean> sr = new ServerResponse<Boolean>();
boolean isPrimarySite = SvcBackupUtil.getPrimarySites().contains(
request.getSiteID());
sr.setPayload(isPrimarySite);
return sr; return sr;
} }
public boolean isNationalCenter() {
return SvcBackupUtil.ncCheck();
}
} }

View file

@ -19,24 +19,17 @@
**/ **/
package com.raytheon.edex.plugin.gfe.svcbackup; package com.raytheon.edex.plugin.gfe.svcbackup;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Properties;
import java.util.Set;
import java.util.TimerTask; import java.util.TimerTask;
import com.google.common.collect.Sets;
import com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportGridsRequestHandler; import com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportGridsRequestHandler;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest; import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest.ExportGridsMode; import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest.ExportGridsMode;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.site.SiteAwareRegistry;
/** /**
* TODO Add Description * Cron job that exports GFE's primary sites' grids. Primary sites are
* determined by a combination of the env. variable AW_SITE_IDENTIFIER and the
* PRIMARY_SITES entry in svcbu.properties.
* *
* <pre> * <pre>
* *
@ -47,6 +40,8 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
* Aug 03, 2011 bphillip Initial creation * Aug 03, 2011 bphillip Initial creation
* Apr 30, 2013 #1761 dgilling Read list of sites to export grids * Apr 30, 2013 #1761 dgilling Read list of sites to export grids
* for from svcbu.properties. * for from svcbu.properties.
* May 02, 2013 #1762 dgilling Move code to read PRIMARY_SITES setting
* to SvcBackupUtil.
* *
* </pre> * </pre>
* *
@ -56,9 +51,6 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
public class ExportGridsTask extends TimerTask { public class ExportGridsTask extends TimerTask {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportGridsTask.class);
public ExportGridsTask(Date executionTime) { public ExportGridsTask(Date executionTime) {
ServiceBackupNotificationManager ServiceBackupNotificationManager
.sendMessageNotification("Export grids cron scheduled for execution at: " .sendMessageNotification("Export grids cron scheduled for execution at: "
@ -74,7 +66,7 @@ public class ExportGridsTask extends TimerTask {
public void run() { public void run() {
final ExportGridsRequestHandler reqHandler = new ExportGridsRequestHandler(); final ExportGridsRequestHandler reqHandler = new ExportGridsRequestHandler();
for (String site : getSites()) { for (String site : SvcBackupUtil.getPrimarySites()) {
ServiceBackupNotificationManager ServiceBackupNotificationManager
.sendMessageNotification("Export Grids to central server cron started for site " .sendMessageNotification("Export Grids to central server cron started for site "
+ site + "."); + site + ".");
@ -88,35 +80,4 @@ public class ExportGridsTask extends TimerTask {
} }
} }
} }
private Collection<String> getSites() {
Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
String siteList = SiteUtil.getSite();
if (svcbuProps != null) {
String propVal = svcbuProps.getProperty("PRIMARY_SITES", "").trim();
if (!propVal.isEmpty()) {
siteList = propVal;
}
}
String[] sites = siteList.split(",");
Collection<String> retVal = new ArrayList<String>(sites.length);
Set<String> validSites = Sets.newHashSet(SiteAwareRegistry
.getInstance().getActiveSites());
for (String site : sites) {
final String siteId = site.trim().toUpperCase();
if (!siteId.isEmpty()) {
if (validSites.contains(siteId)) {
retVal.add(siteId);
} else {
statusHandler
.warn("Site "
+ siteId
+ " is not a currently activated site. Grids will not be exported for this site. Check the PRIMARY_SITES setting in svcbu.properties.");
}
}
}
return retVal;
}
} }

View file

@ -24,11 +24,15 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.google.common.collect.Sets;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.auth.exception.AuthorizationException; import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException; import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
@ -43,6 +47,7 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.auth.roles.IRoleStorage; import com.raytheon.uf.edex.auth.roles.IRoleStorage;
import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.props.PropertiesFactory; import com.raytheon.uf.edex.core.props.PropertiesFactory;
import com.raytheon.uf.edex.site.SiteAwareRegistry;
/** /**
* *
@ -57,6 +62,9 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
* Sep 19, 2011 10955 rferrel make sure process destroy is called. * Sep 19, 2011 10955 rferrel make sure process destroy is called.
* Jun 12, 2012 00609 djohnson Use EDEXUtil for EDEX_HOME. * Jun 12, 2012 00609 djohnson Use EDEXUtil for EDEX_HOME.
* Nov 15, 2012 15614 jdynina Added check for national center * Nov 15, 2012 15614 jdynina Added check for national center
* May 02, 2013 #1762 dgilling Remove check for national center, add
* method to retrieve list of svcbu
* sites.
* *
* </pre> * </pre>
* *
@ -77,6 +85,16 @@ public class SvcBackupUtil {
protected static transient Log logger = LogFactory protected static transient Log logger = LogFactory
.getLog(SvcBackupUtil.class); .getLog(SvcBackupUtil.class);
/**
* A private constructor so that Java does not attempt to create one for us.
* As this class should not be instantiated, do not attempt to ever call
* this constructor; it will simply throw an AssertionError.
*
*/
private SvcBackupUtil() {
throw new AssertionError();
}
public static String execute(String... args) throws Exception { public static String execute(String... args) throws Exception {
String[] newArgs = new String[args.length + 1]; String[] newArgs = new String[args.length + 1];
newArgs[0] = "sh"; newArgs[0] = "sh";
@ -240,17 +258,11 @@ public class SvcBackupUtil {
String lockDir = SvcBackupUtil.getSvcBackupProperties().getProperty( String lockDir = SvcBackupUtil.getSvcBackupProperties().getProperty(
"LOCK_DIR") "LOCK_DIR")
+ File.separator; + File.separator;
lockDir = lockDir.replace("${GFESUITE_HOME}",
EDEXUtil.EDEX_HOME + "/../GFESuite"
+ File.separator);
return lockDir; return lockDir;
} }
public static AuthorizationResponse authorizeWithLocalization( public static AuthorizationResponse authorizeWithLocalization(IUser user,
IUser user, AbstractGfePrivilegedRequest request) throws AuthorizationException {
AbstractGfePrivilegedRequest request)
throws AuthorizationException {
AuthManager manager = AuthManagerFactory.getInstance().getManager(); AuthManager manager = AuthManagerFactory.getInstance().getManager();
IRoleStorage roles = manager.getRoleStorage(); IRoleStorage roles = manager.getRoleStorage();
String roleId = request.getRoleId(); String roleId = request.getRoleId();
@ -264,13 +276,34 @@ IUser user,
+ roleId); + roleId);
} }
public static Set<String> getPrimarySites() {
public static boolean ncCheck() { Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
String nationalCenter = SvcBackupUtil.getSvcBackupProperties() String siteList = SiteUtil.getSite();
.getProperty("NATIONAL_CENTER"); if (svcbuProps != null) {
if (nationalCenter.equals("1")) { String propVal = svcbuProps.getProperty("PRIMARY_SITES", "").trim();
return true; if (!propVal.isEmpty()) {
siteList = propVal;
} }
return false; }
String[] sites = siteList.split(",");
Set<String> retVal = new HashSet<String>(sites.length, 1.0f);
Set<String> validSites = Sets.newHashSet(SiteAwareRegistry
.getInstance().getActiveSites());
for (String site : sites) {
String siteId = site.trim().toUpperCase();
if (!siteId.isEmpty()) {
if (validSites.contains(siteId)) {
retVal.add(siteId);
} else {
final String msg = "Service backup primary site "
+ site
+ " is not a currently activated site. Service backup and export grids tasks cannot be run for this site. Check the PRIMARY_SITES setting in svcbu.properties.";
statusHandler.warn(msg);
}
}
}
return retVal;
} }
} }

View file

@ -19,10 +19,9 @@
**/ **/
package com.raytheon.uf.common.dataplugin.gfe.request; package com.raytheon.uf.common.dataplugin.gfe.request;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/** /**
* TODO Add Description * Request to determine whether specified site id is one of the server's
* configured primary sites for service backup.
* *
* <pre> * <pre>
* *
@ -30,18 +29,14 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2012 jdynina Initial creation * May 02, 2013 dgilling Initial creation
* *
* </pre> * </pre>
* *
* @author jdynina * @author dgilling
* @version 1.0 * @version 1.0
*/ */
@DynamicSerialize public class CheckServiceBackupPrimarySiteRequest extends AbstractGfeRequest {
public class NcCheckRequest extends AbstractGfeRequest {
public NcCheckRequest() {
}
} }

View file

@ -86,13 +86,6 @@
# 2 = grids are exported only by the service backup GUI and from GFE via the 'Send # 2 = grids are exported only by the service backup GUI and from GFE via the 'Send
# Grids to NDFD...' script' # Grids to NDFD...' script'
# #
# NATIONAL_CENTER Indicates that the site is a national center
# This will allow for special treatment of national centers
# when determining site id's. For crons these come from AW_SITE_IDENTIFIER at regular sites.
# At national centers the values will come from activeSites.txt
# VALID VALUES: 0 = this site is not a national center
# 1 = this site is a national center
#
# SVCBU_USER Indicates that the site can configure a special user to # SVCBU_USER Indicates that the site can configure a special user to
# run GFE when in service backup # run GFE when in service backup
# VALID VALUES: 0 = do not use a designated user to run # VALID VALUES: 0 = do not use a designated user to run
@ -111,15 +104,15 @@
# #
# #
# Directories used by Service Backup # Directories used by Service Backup
GFESUITE_HOME=${AWIPS_HOME}/GFESuite GFESUITE_HOME=/awips2/GFESuite
GFESUITE_BIN=${GFESUITE_HOME}/bin GFESUITE_BIN=/awips2/GFESuite/bin
SVCBU_HOME=${GFESUITE_HOME}/ServiceBackup/svcbu SVCBU_HOME=/awips2/GFESuite/ServiceBackup/svcbu
LOCALIZATION_PATH=${AWIPS_HOME}/edex/data/utility LOCALIZATION_PATH=/awips2/edex/data/utility
IFPS_LOG=${GFESUITE_HOME}/ServiceBackup/logs IFPS_LOG=/awips2/GFESuite/ServiceBackup/logs
IFPS_DATA=${GFESUITE_HOME}/ServiceBackup/data IFPS_DATA=/awips2/GFESuite/ServiceBackup/data
LOCK_DIR=${GFESUITE_HOME}/ServiceBackup/locks LOCK_DIR=/awips2/GFESuite/ServiceBackup/locks
SCRIPTS_DIR=${GFESUITE_HOME}/ServiceBackup/scripts SCRIPTS_DIR=/awips2/GFESuite/ServiceBackup/scripts
CAVE_LAUNCH_SCRIPT=${AWIPS_HOME}/cave/cave.sh CAVE_LAUNCH_SCRIPT=/awips2/cave/cave.sh
SVCBU_HOST=ec SVCBU_HOST=ec
MSG_SEND_COMMAND=msg_send MSG_SEND_COMMAND=msg_send
@ -133,4 +126,4 @@ SVCBU_WMO_HEADER=SVCBKPIFP
SVCBU_USER=0 SVCBU_USER=0
SVCBU_USER_ID="" SVCBU_USER_ID=""
EXPORT_GRID=1 EXPORT_GRID=1
NATIONAL_CENTER=0 PRIMARY_SITES=