Issue #1966 Relocation of configuration files and checks for bad configuration files.
Change-Id: I1e26806cfc27eb25d0f3b8c1ad6ed21bfaebfc9c Former-commit-id:c002045a87
[formerlyc002045a87
[formerly d8b89bcf2bb65e3e54730e58ab7529f03fcbbaad]] Former-commit-id:91ee1d36bf
Former-commit-id:95cb3439a4
This commit is contained in:
parent
c6c8c3c2d0
commit
47ac9a9147
9 changed files with 53 additions and 37 deletions
|
@ -25,8 +25,8 @@
|
|||
<path
|
||||
application="Archive"
|
||||
localizationType="COMMON_STATIC"
|
||||
name="Archive"
|
||||
value="archive"
|
||||
name="Configuration"
|
||||
value="archiver/purger"
|
||||
recursive="false"
|
||||
extensionFilter=".xml">
|
||||
</path>
|
||||
|
|
|
@ -279,7 +279,6 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
|||
Job job = new Job("setup") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
ArchiveConfigManager.getInstance().reset();
|
||||
if (!shell.isDisposed()) {
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
|
@ -555,4 +554,16 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
|||
protected void removeModifiedListener(IModifyListener iModifyListener) {
|
||||
tableComp.removeModifiedListener(iModifyListener);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
ArchiveConfigManager.getInstance().reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ public class ArchiveRetentionDlg extends AbstractArchiveDlg implements
|
|||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
super.initializeComponents(shell);
|
||||
setText("Archive Retention");
|
||||
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(1, false);
|
||||
|
@ -126,8 +127,6 @@ public class ArchiveRetentionDlg extends AbstractArchiveDlg implements
|
|||
gl.marginWidth = 0;
|
||||
gl.horizontalSpacing = 0;
|
||||
mainComp.setLayout(gl);
|
||||
ArchiveConfigManager.getInstance().reset();
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.eclipse.swt.widgets.MessageBox;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||
import com.raytheon.uf.common.archive.config.DisplayData;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.SizeUtil;
|
||||
|
@ -136,9 +135,6 @@ public class CaseCreationDlg extends AbstractArchiveDlg implements
|
|||
private SimpleDateFormat dateFmt = new SimpleDateFormat(
|
||||
"E MMM dd yyyy HH:00 z");
|
||||
|
||||
/** Archive configuration manager */
|
||||
private ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||
|
||||
/** Number of selected items. */
|
||||
private int selectedItemsSize = 0;
|
||||
|
||||
|
@ -179,6 +175,7 @@ public class CaseCreationDlg extends AbstractArchiveDlg implements
|
|||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
super.initializeComponents(shell);
|
||||
setText("Archive Case Creation");
|
||||
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(1, false);
|
||||
|
@ -186,9 +183,6 @@ public class CaseCreationDlg extends AbstractArchiveDlg implements
|
|||
gl.marginWidth = 0;
|
||||
gl.horizontalSpacing = 0;
|
||||
mainComp.setLayout(gl);
|
||||
|
||||
manager.reset();
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,19 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
this.categoryList = categoryList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for required entries.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (name != null) && (rootDir != null) && (categoryList != null)
|
||||
&& (categoryList.size() > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(ArchiveConfig o) {
|
||||
return getName().compareToIgnoreCase(o.getName());
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.util.TreeSet;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.bind.DataBindingException;
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -91,7 +92,7 @@ public class ArchiveConfigManager {
|
|||
private final static ArchiveConfigManager instance = new ArchiveConfigManager();
|
||||
|
||||
/** Localize directory for the archive configuration files. */
|
||||
public final String ARCHIVE_DIR = "archive";
|
||||
public final String ARCHIVE_DIR = "archiver/purger";
|
||||
|
||||
/** Localization manager. */
|
||||
private IPathManager pathMgr;
|
||||
|
@ -169,19 +170,6 @@ public class ArchiveConfigManager {
|
|||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the archiveConfig information from the localized file.
|
||||
*
|
||||
* @param lFile
|
||||
* @return archiveConfig
|
||||
* @throws IOException
|
||||
* @throws LocalizationException
|
||||
*/
|
||||
public ArchiveConfig loadArchiveData(LocalizationFile lFile)
|
||||
throws IOException, LocalizationException {
|
||||
return unmarshalArhiveConfigFromXmlFile(lFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Collection of Archives.
|
||||
*/
|
||||
|
@ -282,9 +270,9 @@ public class ArchiveConfigManager {
|
|||
Calendar purgeTime = calculateExpiration(archive, category);
|
||||
CategoryFileDateHelper helper = new CategoryFileDateHelper(
|
||||
category, archive.getRootDir());
|
||||
IOFileFilter fileDateFilter = FileFilterUtils.and(
|
||||
FileFilterUtils.fileFileFilter(),
|
||||
new FileDateFilter(null, purgeTime, helper));
|
||||
IOFileFilter fileDateFilter = FileFilterUtils.and(FileFilterUtils
|
||||
.fileFileFilter(), new FileDateFilter(null, purgeTime,
|
||||
helper));
|
||||
|
||||
// Remove the directory associated with this category from the not
|
||||
// purged list since it is being purged.
|
||||
|
@ -322,8 +310,8 @@ public class ArchiveConfigManager {
|
|||
return filesPurged;
|
||||
}
|
||||
|
||||
private Collection<File> purgeFile(File fileToPurge,
|
||||
IOFileFilter filter, final String archiveRootDir) {
|
||||
private Collection<File> purgeFile(File fileToPurge, IOFileFilter filter,
|
||||
final String archiveRootDir) {
|
||||
Collection<File> filesPurged = new ArrayList<File>();
|
||||
|
||||
if (fileToPurge.isFile() && filter.accept(fileToPurge)) {
|
||||
|
@ -403,9 +391,19 @@ public class ArchiveConfigManager {
|
|||
for (LocalizationFile lFile : files) {
|
||||
try {
|
||||
ArchiveConfig archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile);
|
||||
archiveNameToLocalizationFileMap.put(archiveConfig.getName(),
|
||||
lFile);
|
||||
archiveMap.put(archiveConfig.getName(), archiveConfig);
|
||||
if (archiveConfig != null && archiveConfig.isValid()) {
|
||||
archiveNameToLocalizationFileMap.put(
|
||||
archiveConfig.getName(), lFile);
|
||||
archiveMap.put(archiveConfig.getName(), archiveConfig);
|
||||
} else {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Bad Archive configuration file: "
|
||||
+ lFile.getFile().getName());
|
||||
}
|
||||
} catch (DataBindingException ex) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Bad Archive configuration file \""
|
||||
+ lFile.getFile().getName() + "\": ", ex);
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
|
@ -771,7 +769,8 @@ public class ArchiveConfigManager {
|
|||
* @throws LocalizationException
|
||||
*/
|
||||
private ArchiveConfig unmarshalArhiveConfigFromXmlFile(
|
||||
LocalizationFile lFile) throws IOException, LocalizationException {
|
||||
LocalizationFile lFile) throws IOException, LocalizationException,
|
||||
DataBindingException {
|
||||
ArchiveConfig archiveConfig = null;
|
||||
LocalizationFileInputStream stream = null;
|
||||
try {
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
|
||||
<permission id="com.raytheon.localization.site/common_static/datadelivery"/>
|
||||
|
||||
<permission id="com.raytheon.localization.site/common_static/archive"/>
|
||||
<permission id="com.raytheon.localization.site/common_static/archiver/purger"/>
|
||||
|
||||
<user userId="ALL">
|
||||
<userPermission>com.raytheon.localization.site/common_static/purge</userPermission>
|
||||
|
@ -124,7 +124,7 @@
|
|||
<userPermission>com.raytheon.localization.site/common_static/shef</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/roles</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/datadelivery</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/archive</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/archiver/purger</userPermission>
|
||||
</user>
|
||||
</nwsRoleData>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue