Issue #2361 Centralized serialization to the HarvesterConfigurationManager.
Former-commit-id:91e69b800d
[formerlyf5b9d3be39
] [formerly 7d0bb5825fabe6056e054ebed4b8de6346b820b9 [formerly6cb541d1a1
]] [formerly15aed68c02
[formerly6cb541d1a1
[formerly ded6bbf39f6d6fe05f31d61f310e7473d55a6643]]] Former-commit-id:15aed68c02
Former-commit-id: 0423445a8ccf01b94283305bba59e4481390d48e [formerlya8ab9072cc
] Former-commit-id:b5e309f973
This commit is contained in:
parent
fea475b821
commit
ba1de528c3
7 changed files with 61 additions and 42 deletions
|
@ -20,6 +20,7 @@ package com.raytheon.uf.common.datadelivery.harvester;
|
|||
* further licensing information.
|
||||
**/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -79,13 +80,7 @@ public class HarvesterConfigurationManager {
|
|||
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
try {
|
||||
config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile());
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Can't deserialize harvester config at "
|
||||
+ lf.getFile().getPath(), e);
|
||||
}
|
||||
config = getHarvesterFile(lf.getFile());
|
||||
|
||||
if (config != null) {
|
||||
Agent agent = config.getAgent();
|
||||
|
@ -110,13 +105,7 @@ public class HarvesterConfigurationManager {
|
|||
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
try {
|
||||
config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile());
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Can't deserialize harvester config at "
|
||||
+ lf.getFile().getPath(), e);
|
||||
}
|
||||
config = getHarvesterFile(lf.getFile());
|
||||
|
||||
if (config != null) {
|
||||
Agent agent = config.getAgent();
|
||||
|
@ -132,4 +121,39 @@ public class HarvesterConfigurationManager {
|
|||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this harvester configuration File
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static HarvesterConfig getHarvesterFile(File file) {
|
||||
|
||||
HarvesterConfig config = null;
|
||||
|
||||
try {
|
||||
config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file);
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Can't deserialize harvester config at "
|
||||
+ file.getPath(), e);
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the harvester config files
|
||||
* @param config
|
||||
* @param file
|
||||
*/
|
||||
public static void setHarvesterFile(HarvesterConfig config, File file) {
|
||||
try {
|
||||
HarvesterJaxbManager.getJaxb().marshalToXmlFile(config,
|
||||
file.getAbsolutePath());
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR, "Couldn't write Harvester Config file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Set;
|
|||
import com.raytheon.uf.common.datadelivery.harvester.Agent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Collection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Utils;
|
||||
|
@ -99,9 +99,9 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
|
|||
|
||||
if (files != null) {
|
||||
for (LocalizationFile file : files) {
|
||||
|
||||
try {
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file.getFile());
|
||||
HarvesterConfig hc = HarvesterConfigurationManager
|
||||
.getHarvesterFile(file.getFile());
|
||||
Agent agent = hc.getAgent();
|
||||
|
||||
if (agent != null) {
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.quartz.JobExecutionException;
|
|||
import com.raytheon.uf.common.datadelivery.harvester.Agent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -143,9 +143,10 @@ public abstract class CrawlLauncher implements Job {
|
|||
|
||||
if (files != null) {
|
||||
for (LocalizationFile lf : files) {
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
|
||||
HarvesterConfig hc = HarvesterConfigurationManager
|
||||
.getHarvesterFile(lf.getFile());
|
||||
|
||||
if (hc.getAgent() != null) {
|
||||
// we only want crawler types for CrawlerMetadata
|
||||
Agent agent = hc.getAgent();
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.raytheon.edex.util.Util;
|
|||
import com.raytheon.uf.common.comm.ProxyConfiguration;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Collection;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
@ -139,10 +140,9 @@ public abstract class Crawler {
|
|||
HarvesterConfig hc = null;
|
||||
|
||||
try {
|
||||
hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(
|
||||
HarvesterConfig.class, configFile);
|
||||
} catch (SerializationException e1) {
|
||||
e1.printStackTrace();
|
||||
hc = HarvesterConfigurationManager.getHarvesterFile(configFile);
|
||||
} catch (Exception e1) {
|
||||
statusHandler.handle(Priority.ERROR, e1.getLocalizedMessage(), e1);
|
||||
}
|
||||
|
||||
return hc;
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.regex.Pattern;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.ProtoCollection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Collection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
|
@ -44,7 +44,6 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
|
||||
import com.raytheon.uf.common.serialization.ExceptionWrapper;
|
||||
import com.raytheon.uf.common.serialization.SerializableExceptionWrapper;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
@ -74,7 +73,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore;
|
|||
* Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting.
|
||||
* Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order.
|
||||
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
* * Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -375,18 +374,15 @@ class FileCommunicationStrategy implements CommunicationStrategy {
|
|||
File file = lf.getFile();
|
||||
|
||||
try {
|
||||
HarvesterJaxbManager.getJaxb().marshalToXmlFile(hconfig,
|
||||
file.getAbsolutePath());
|
||||
HarvesterConfigurationManager.setHarvesterFile(hconfig, file);
|
||||
lf.save();
|
||||
} catch (SerializationException e) {
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.error("Unable to recreate the "
|
||||
+ provider
|
||||
+ "-harvester.xml configuration! Save of new collections failed",
|
||||
e);
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import com.raytheon.uf.common.datadelivery.harvester.Agent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -79,9 +79,9 @@ public class MainSequenceCrawlLauncher extends CrawlLauncher {
|
|||
// if many, start many
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
HarvesterConfig hc = HarvesterConfigurationManager
|
||||
.getHarvesterFile(lf.getFile());
|
||||
|
||||
if (hc.getProvider().getName().equals(providerName)) {
|
||||
if (hc.getAgent() != null) {
|
||||
// we only want crawler types for CrawlerMetadata
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import com.raytheon.uf.common.datadelivery.harvester.Agent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -77,9 +77,7 @@ public class SeedCrawlLauncher extends CrawlLauncher {
|
|||
// if many, start many
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
HarvesterConfig hc = HarvesterConfigurationManager.getHarvesterFile(lf.getFile());
|
||||
|
||||
if (hc.getProvider().getName().equals(providerName)) {
|
||||
if (hc.getAgent() != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue