ASM #15052 - WarnGen: service backup should use config.xml from failed site
Change-Id: Icff8ca2a124da595be6b83ac9f9999831daee0b1 Former-commit-id:59c9cbaaa6
[formerlyb82fb691e0
] [formerly8784501bba
] [formerly 67793d144b6797160231fd12dc14ed66e86ebdf8 [formerly8784501bba
[formerlya45fe1dad0
]]] [formerlydb8977e281
[formerly8784501bba
[formerlya45fe1dad0
] [formerlydb8977e281
[formerly f9c0dc09ee7bc692c6f70b4a5ad67bb2c2ed5a20]]]] Former-commit-id:db8977e281
Former-commit-id: daaf4137f805b88b1f758e9eab9d6335dafc253c [formerly c850f84db3b8b601f2bbda41059ace7ce49e7f85] [formerly5270711c5d
[formerlyd36834080e
]] Former-commit-id:5270711c5d
Former-commit-id:363de7a3c5
This commit is contained in:
parent
e890482d79
commit
7f9e063375
4 changed files with 191 additions and 51 deletions
|
@ -154,6 +154,7 @@ import com.vividsolutions.jts.geom.Polygon;
|
||||||
* Oct 01, 2013 DR16612 m.gamazaychikov Fixed inconsistencies with track locking and updateListSelected method
|
* Oct 01, 2013 DR16612 m.gamazaychikov Fixed inconsistencies with track locking and updateListSelected method
|
||||||
* Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the polygon the be used.
|
* Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the polygon the be used.
|
||||||
* Apr 28, 2014 3033 jsanchez Re-initialized the Velocity Engine when switching back up sites.
|
* Apr 28, 2014 3033 jsanchez Re-initialized the Velocity Engine when switching back up sites.
|
||||||
|
* Jul 01, 2014 DR 17450 D. Friedman Use list of templates from backup site.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -482,30 +483,39 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
* @param productType2
|
* @param productType2
|
||||||
*/
|
*/
|
||||||
private void createOtherProductsList(Group productType2) {
|
private void createOtherProductsList(Group productType2) {
|
||||||
other = new Button(productType, SWT.RADIO);
|
if (other == null) {
|
||||||
other.setText("Other:");
|
other = new Button(productType, SWT.RADIO);
|
||||||
other.setEnabled(true);
|
other.setText("Other:");
|
||||||
other.addSelectionListener(new SelectionAdapter() {
|
other.setEnabled(true);
|
||||||
|
other.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent arg0) {
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
otherSelected();
|
otherSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
otherProductListCbo = new Combo(productType, SWT.READ_ONLY
|
||||||
|
| SWT.DROP_DOWN);
|
||||||
|
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
||||||
|
otherProductListCbo.setLayoutData(gd);
|
||||||
|
otherProductListCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
|
otherProductSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
other.setSelection(false);
|
||||||
|
if (mainProductBtns.length > 0 && mainProductBtns.length > 0) {
|
||||||
|
other.moveBelow(mainProductBtns[mainProductBtns.length - 1]);
|
||||||
}
|
}
|
||||||
|
otherProductListCbo.moveBelow(other);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
otherProductListCbo = new Combo(productType, SWT.READ_ONLY
|
|
||||||
| SWT.DROP_DOWN);
|
|
||||||
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
|
||||||
otherProductListCbo.setLayoutData(gd);
|
|
||||||
updateOtherProductList(otherProductListCbo);
|
updateOtherProductList(otherProductListCbo);
|
||||||
otherProductListCbo.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent arg0) {
|
|
||||||
otherProductSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMainProductButtons(Group productType) {
|
private void createMainProductButtons(Group productType) {
|
||||||
|
@ -517,12 +527,13 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
mainProducts.add(str);
|
mainProducts.add(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
String defaultTemplate = warngenLayer.getDialogConfig()
|
String defaultTemplate = getDefaultTemplate();
|
||||||
.getDefaultTemplate();
|
|
||||||
if ((defaultTemplate == null) || defaultTemplate.equals("")) {
|
|
||||||
defaultTemplate = mainProducts.get(0).split("/")[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (mainProductBtns != null) {
|
||||||
|
for (Button button : mainProductBtns) {
|
||||||
|
button.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
mainProductBtns = new Button[mainProducts.size()];
|
mainProductBtns = new Button[mainProducts.size()];
|
||||||
|
|
||||||
if (mainProducts.size() > 0) {
|
if (mainProducts.size() > 0) {
|
||||||
|
@ -538,24 +549,28 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
mainProductBtns[0].addSelectionListener(new SelectionAdapter() {
|
mainProductBtns[0].addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
changeTemplate(mainProducts.get(0).split("/")[1]);
|
uiChangeTemplate(mainProducts.get(0).split("/")[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
||||||
gd.horizontalIndent = 30;
|
if (updateListCbo == null) {
|
||||||
updateListCbo = new Combo(productType, SWT.READ_ONLY | SWT.DROP_DOWN);
|
gd.horizontalIndent = 30;
|
||||||
updateListCbo.setLayoutData(gd);
|
updateListCbo = new Combo(productType, SWT.READ_ONLY | SWT.DROP_DOWN);
|
||||||
recreateUpdates();
|
updateListCbo.setLayoutData(gd);
|
||||||
|
recreateUpdates();
|
||||||
|
|
||||||
updateListCbo.addSelectionListener(new SelectionAdapter() {
|
updateListCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent arg0) {
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
updateListSelected();
|
updateListSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
} else if (mainProductBtns.length > 0) {
|
||||||
|
updateListCbo.moveBelow(mainProductBtns[0]);
|
||||||
|
}
|
||||||
|
|
||||||
for (int cnt = 1; cnt < mainProducts.size(); cnt++) {
|
for (int cnt = 1; cnt < mainProducts.size(); cnt++) {
|
||||||
final String[] tmp = mainProducts.get(cnt).split("/");
|
final String[] tmp = mainProducts.get(cnt).split("/");
|
||||||
|
@ -584,7 +599,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeTemplate(templateName);
|
uiChangeTemplate(templateName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -681,7 +696,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
backupGroup.setLayout(new GridLayout(2, false));
|
backupGroup.setLayout(new GridLayout(2, false));
|
||||||
|
|
||||||
Label label2 = new Label(backupGroup, SWT.BOLD);
|
Label label2 = new Label(backupGroup, SWT.BOLD);
|
||||||
label2.setText("Full:");
|
label2.setText("WFO:");
|
||||||
label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
backupSiteCbo = new Combo(backupGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
|
backupSiteCbo = new Combo(backupGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
|
||||||
backupSiteCbo.addSelectionListener(new SelectionAdapter() {
|
backupSiteCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@ -1320,9 +1335,28 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
} else {
|
} else {
|
||||||
new TemplateRunnerInitJob(backupSite).schedule();
|
new TemplateRunnerInitJob(backupSite).schedule();
|
||||||
}
|
}
|
||||||
// Refresh template
|
|
||||||
changeTemplate(warngenLayer.getTemplateName());
|
/*
|
||||||
resetPressed();
|
* When the product selection buttons are recreated below, the
|
||||||
|
* button for the default template will be selected and mainProducts
|
||||||
|
* will have been recreated. Then getDefaultTemplate() can be used
|
||||||
|
* here to change the state.
|
||||||
|
*/
|
||||||
|
createMainProductButtons(productType);
|
||||||
|
createOtherProductsList(productType);
|
||||||
|
|
||||||
|
// Don't let errors prevent the new controls from being displayed!
|
||||||
|
try {
|
||||||
|
changeTemplate(getDefaultTemplate());
|
||||||
|
resetPressed();
|
||||||
|
} catch (Exception e) {
|
||||||
|
statusHandler
|
||||||
|
.error("Error occurred while switching to the default template.",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
|
||||||
|
productType.layout(true, true);
|
||||||
|
getShell().pack(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backupSiteCbo.getSelectionIndex() == 0) {
|
if (backupSiteCbo.getSelectionIndex() == 0) {
|
||||||
|
@ -1483,6 +1517,19 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called by controls that can change the current template. Do not
|
||||||
|
* do anything if the request template is already selected. This
|
||||||
|
* check is necessary to prevent certain state being reset if
|
||||||
|
* a followup has been selected as this is not handled by
|
||||||
|
* changeTemplate() (DR 14515.)
|
||||||
|
*/
|
||||||
|
private void uiChangeTemplate(String templateName) {
|
||||||
|
if (templateName.equals(warngenLayer.getTemplateName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
changeTemplate(templateName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method updates the Warngen Layer and Warngen Dialog based on a new
|
* This method updates the Warngen Layer and Warngen Dialog based on a new
|
||||||
* template selection. This method should also be called when the CWA is
|
* template selection. This method should also be called when the CWA is
|
||||||
|
@ -1495,11 +1542,6 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
*/
|
*/
|
||||||
private void changeTemplate(String templateName) {
|
private void changeTemplate(String templateName) {
|
||||||
|
|
||||||
// DR 14515
|
|
||||||
if (templateName.equals(warngenLayer.getTemplateName())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String lastAreaSource = warngenLayer.getConfiguration()
|
String lastAreaSource = warngenLayer.getConfiguration()
|
||||||
.getHatchedAreaSource().getAreaSource();
|
.getHatchedAreaSource().getAreaSource();
|
||||||
|
|
||||||
|
@ -1634,6 +1676,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
otherProducts = new HashMap<String, String>();
|
otherProducts = new HashMap<String, String>();
|
||||||
String[] otherProductsStr = warngenLayer.getDialogConfig()
|
String[] otherProductsStr = warngenLayer.getDialogConfig()
|
||||||
.getOtherWarngenProducts().split(",");
|
.getOtherWarngenProducts().split(",");
|
||||||
|
theList.removeAll();
|
||||||
for (String str : otherProductsStr) {
|
for (String str : otherProductsStr) {
|
||||||
String[] s = str.split("/");
|
String[] s = str.split("/");
|
||||||
otherProducts.put(s[0], s[1]);
|
otherProducts.put(s[0], s[1]);
|
||||||
|
@ -1784,7 +1827,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
templateName = otherProducts.get(otherProductListCbo
|
templateName = otherProducts.get(otherProductListCbo
|
||||||
.getItem(otherProductListCbo.getSelectionIndex()));
|
.getItem(otherProductListCbo.getSelectionIndex()));
|
||||||
}
|
}
|
||||||
changeTemplate(templateName);
|
uiChangeTemplate(templateName);
|
||||||
otherProductListCbo.pack(true);
|
otherProductListCbo.pack(true);
|
||||||
productType.layout();
|
productType.layout();
|
||||||
|
|
||||||
|
@ -2251,7 +2294,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
templateName = otherProducts.get(otherProductListCbo
|
templateName = otherProducts.get(otherProductListCbo
|
||||||
.getItem(otherProductListCbo.getSelectionIndex()));
|
.getItem(otherProductListCbo.getSelectionIndex()));
|
||||||
}
|
}
|
||||||
changeTemplate(templateName);
|
uiChangeTemplate(templateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshDisplay() {
|
private void refreshDisplay() {
|
||||||
|
@ -2503,4 +2546,13 @@ public class WarngenDialog extends CaveSWTDialog implements
|
||||||
warngenLayer.issueRefresh();
|
warngenLayer.issueRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDefaultTemplate() {
|
||||||
|
String defaultTemplate = warngenLayer.getDialogConfig()
|
||||||
|
.getDefaultTemplate();
|
||||||
|
if ((defaultTemplate == null) || defaultTemplate.equals("")) {
|
||||||
|
defaultTemplate = mainProducts.get(0).split("/")[1];
|
||||||
|
}
|
||||||
|
return defaultTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,7 @@ import com.vividsolutions.jts.io.WKTReader;
|
||||||
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
|
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
|
||||||
* 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected.
|
* 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected.
|
||||||
* 05/16/2014 DR 17365 D. Friedman Check if moved vertex results in polygon valid in both lat/lon and local coordinates.
|
* 05/16/2014 DR 17365 D. Friedman Check if moved vertex results in polygon valid in both lat/lon and local coordinates.
|
||||||
|
* 07/01/2014 DR 17450 D. Friedman Use list of templates from backup site.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mschenke
|
* @author mschenke
|
||||||
|
@ -1370,6 +1371,49 @@ public class WarngenLayer extends AbstractStormTrackResource {
|
||||||
} else {
|
} else {
|
||||||
backupSite = site;
|
backupSite = site;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogConfiguration dc = null;
|
||||||
|
if (backupSite != null) {
|
||||||
|
boolean haveBackupConfig = DialogConfiguration.isSiteDialogConfigExtant(backupSite);
|
||||||
|
if (haveBackupConfig) {
|
||||||
|
try {
|
||||||
|
dc = DialogConfiguration.loadDialogConfigNoUser(backupSite);
|
||||||
|
} catch (Exception e) {
|
||||||
|
statusHandler.error(String.format(
|
||||||
|
"Unable to load WarnGen configuration for site %s. Falling back to local configuration.",
|
||||||
|
getLocalizedSite()), e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
statusHandler.warn(String.format(
|
||||||
|
"WarnGen configuration for site %s does not exist. Falling back to local configuration.",
|
||||||
|
backupSite));
|
||||||
|
}
|
||||||
|
if (dc == null) {
|
||||||
|
try {
|
||||||
|
dc = DialogConfiguration.loadDialogConfigNoUser(LocalizationManager
|
||||||
|
.getInstance().getCurrentSite());
|
||||||
|
} catch (Exception e) {
|
||||||
|
dc = new DialogConfiguration();
|
||||||
|
statusHandler.error(String.format(
|
||||||
|
"Unable to load WarnGen configuration for site %s.",
|
||||||
|
getLocalizedSite()), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
dc = DialogConfiguration.loadDialogConfig(LocalizationManager
|
||||||
|
.getInstance().getCurrentSite());
|
||||||
|
} catch (Exception e) {
|
||||||
|
dc = new DialogConfiguration();
|
||||||
|
statusHandler.error(
|
||||||
|
"Unable to load local WarnGen configuration.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dc != null && dialogConfig != null) {
|
||||||
|
dialogConfig.setDefaultTemplate(dc.getDefaultTemplate());
|
||||||
|
dialogConfig.setMainWarngenProducts(dc.getMainWarngenProducts());
|
||||||
|
dialogConfig.setOtherWarngenProducts(dc.getOtherWarngenProducts());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocalizedSite() {
|
public String getLocalizedSite() {
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||||
* --/--/---- Initial creation
|
* --/--/---- Initial creation
|
||||||
* 10/22/2013 2361 njensen Use JAXBManager for XML
|
* 10/22/2013 2361 njensen Use JAXBManager for XML
|
||||||
* Apr 28, 2014 3033 jsanchez Refactored file retrieval.
|
* Apr 28, 2014 3033 jsanchez Refactored file retrieval.
|
||||||
|
* Jul 02, 2014 DR 17450 D. Friedman Support using list of templates from backup site.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author jsanchez
|
* @author jsanchez
|
||||||
|
@ -91,6 +92,18 @@ public class DialogConfiguration {
|
||||||
return (DialogConfiguration) jaxb.unmarshalFromXml(xml);
|
return (DialogConfiguration) jaxb.unmarshalFromXml(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DialogConfiguration loadDialogConfigNoUser(String site)
|
||||||
|
throws FileNotFoundException, IOException, JAXBException {
|
||||||
|
String xml = WarnFileUtil.convertFileContentsToStringNoUser(
|
||||||
|
CONFIG_FILE, site);
|
||||||
|
return (DialogConfiguration) jaxb.unmarshalFromXml(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSiteDialogConfigExtant(String backupSite) {
|
||||||
|
return WarnFileUtil.isLocalizationFileExtantAtSiteLevel(CONFIG_FILE,
|
||||||
|
backupSite);
|
||||||
|
}
|
||||||
|
|
||||||
public String getWarngenOfficeShort() {
|
public String getWarngenOfficeShort() {
|
||||||
return warngenOfficeShort;
|
return warngenOfficeShort;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,18 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Apr 28, 2014 3033 jsanchez Searches the backup site directory before the localized site directory.
|
* Apr 28, 2014 3033 jsanchez Searches the backup site directory before the localized site directory.
|
||||||
|
* Jul 02, 2014 DR 17450 D. Friedman Support using list of templates from backup site.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author jsanchez
|
* @author jsanchez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class WarnFileUtil {
|
public class WarnFileUtil {
|
||||||
|
public static LocalizationFile findFileInLocalizationIncludingBackupSite(String filename,
|
||||||
|
String issuingSiteID, String backupSiteID) throws FileNotFoundException {
|
||||||
|
return findFileInLocalizationIncludingBackupSite(filename, issuingSiteID, backupSiteID, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the appropriate file in localization. If a backupSiteID is not
|
* Returns the appropriate file in localization. If a backupSiteID is not
|
||||||
* null and a corresponding file does exist in the backup site directory,
|
* null and a corresponding file does exist in the backup site directory,
|
||||||
|
@ -49,7 +55,7 @@ public class WarnFileUtil {
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public static LocalizationFile findFileInLocalizationIncludingBackupSite(String filename,
|
public static LocalizationFile findFileInLocalizationIncludingBackupSite(String filename,
|
||||||
String issuingSiteID, String backupSiteID)
|
String issuingSiteID, String backupSiteID, boolean allowUser)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
|
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
@ -71,6 +77,9 @@ public class WarnFileUtil {
|
||||||
LocalizationContext[] searchContext = pm
|
LocalizationContext[] searchContext = pm
|
||||||
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
|
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
|
||||||
for (LocalizationContext ctx : searchContext) {
|
for (LocalizationContext ctx : searchContext) {
|
||||||
|
if (!allowUser && ctx.getLocalizationLevel() == LocalizationLevel.USER)
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((ctx.getLocalizationLevel() == LocalizationLevel.SITE || ctx
|
if ((ctx.getLocalizationLevel() == LocalizationLevel.SITE || ctx
|
||||||
.getLocalizationLevel() == LocalizationLevel.CONFIGURED)
|
.getLocalizationLevel() == LocalizationLevel.CONFIGURED)
|
||||||
&& issuingSiteID != null) {
|
&& issuingSiteID != null) {
|
||||||
|
@ -90,6 +99,18 @@ public class WarnFileUtil {
|
||||||
return fileToUse;
|
return fileToUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLocalizationFileExtantAtSiteLevel(String filename, String siteID) {
|
||||||
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
String fileToRetrieve = WarningConstants.WARNGEN_DIR
|
||||||
|
+ IPathManager.SEPARATOR + filename;
|
||||||
|
LocalizationContext backupSiteCtx = pm.getContext(
|
||||||
|
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||||
|
backupSiteCtx.setContextName(siteID);
|
||||||
|
LocalizationFile backupFile = pm.getLocalizationFile(backupSiteCtx,
|
||||||
|
fileToRetrieve);
|
||||||
|
return backupFile != null && backupFile.exists();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates the appropriate file in the localization hierarchy including the
|
* Locates the appropriate file in the localization hierarchy including the
|
||||||
* backupSite directory (if provided) and converts the content of the file
|
* backupSite directory (if provided) and converts the content of the file
|
||||||
|
@ -105,10 +126,20 @@ public class WarnFileUtil {
|
||||||
public static String convertFileContentsToString(String filename,
|
public static String convertFileContentsToString(String filename,
|
||||||
String localizedSite, String backupSite)
|
String localizedSite, String backupSite)
|
||||||
throws FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
BufferedReader input = null;
|
|
||||||
File file = findFileInLocalizationIncludingBackupSite(filename, localizedSite, backupSite)
|
File file = findFileInLocalizationIncludingBackupSite(filename, localizedSite, backupSite)
|
||||||
.getFile();
|
.getFile();
|
||||||
|
return convertFileContentsToString(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertFileContentsToStringNoUser(String filename,
|
||||||
|
String site) throws FileNotFoundException {
|
||||||
|
File file = findFileInLocalizationIncludingBackupSite(filename, site, null, false).getFile();
|
||||||
|
return convertFileContentsToString(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String convertFileContentsToString(File file) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
BufferedReader input = null;
|
||||||
try {
|
try {
|
||||||
input = new BufferedReader(new FileReader(file));
|
input = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue