Merge "Issue #2361 Harvester JAXB fixed up" into development
Former-commit-id:a5f2414070
[formerly 2421a960399e6deeb911cf25f968e6eead666bd6] Former-commit-id:4879c19e0b
This commit is contained in:
commit
4929a59b3e
8 changed files with 129 additions and 27 deletions
|
@ -1,5 +1,25 @@
|
|||
package com.raytheon.uf.common.datadelivery.harvester;
|
||||
|
||||
/**
|
||||
* 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 java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -7,7 +27,6 @@ import com.raytheon.uf.common.localization.IPathManager;
|
|||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -22,6 +41,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* --/--/---- dhladky Initial creation
|
||||
* Oct 23, 2013 2361 njensen Use JAXBManager for XML
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -33,9 +53,6 @@ public class HarvesterConfigurationManager {
|
|||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(HarvesterConfigurationManager.class);
|
||||
|
||||
private static final SingleTypeJAXBManager<HarvesterConfig> jaxb = SingleTypeJAXBManager
|
||||
.createWithoutException(HarvesterConfig.class);
|
||||
|
||||
/**
|
||||
* Gets site and base level configs for harvesters
|
||||
*
|
||||
|
@ -63,7 +80,7 @@ public class HarvesterConfigurationManager {
|
|||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
try {
|
||||
config = jaxb.unmarshalFromXmlFile(lf.getFile());
|
||||
config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile());
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Can't deserialize harvester config at "
|
||||
|
@ -94,7 +111,7 @@ public class HarvesterConfigurationManager {
|
|||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
try {
|
||||
config = jaxb.unmarshalFromXmlFile(lf.getFile());
|
||||
config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile());
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Can't deserialize harvester config at "
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package com.raytheon.uf.common.datadelivery.harvester;
|
||||
|
||||
/**
|
||||
* 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 javax.xml.bind.JAXBException;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Connection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.ProviderType;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
/**
|
||||
* JAXB for Harvester
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 23, 2013 2361 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class HarvesterJaxbManager {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(HarvesterJaxbManager.class);
|
||||
|
||||
private static Class<?>[] clazzess = new Class<?>[] {
|
||||
HarvesterConfig.class, Provider.class, Connection.class,
|
||||
ProviderType.class, ServiceType.class, Agent.class,
|
||||
CrawlAgent.class, OGCAgent.class, ConfigLayer.class };
|
||||
|
||||
private JAXBManager jaxb = null;
|
||||
|
||||
private static HarvesterJaxbManager instance = new HarvesterJaxbManager();
|
||||
|
||||
/**
|
||||
* marshall and unmarshall harvester objects
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static JAXBManager getJaxb() {
|
||||
|
||||
if (instance.jaxb == null) {
|
||||
try {
|
||||
instance.jaxb = new JAXBManager(clazzess);
|
||||
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
return instance.jaxb;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +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.registry.Collection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Utils;
|
||||
|
@ -63,6 +64,7 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
|
|||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* 3/18/2013 1802 bphillip Modified to insert provider object after database is initialized
|
||||
* Jun 24, 2013 2106 djohnson Accepts ProviderHandler as a constructor argument.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,7 +78,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
|
|||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CrawlMetaDataHandler.class);
|
||||
|
||||
|
||||
/** Path to crawler links directory. */
|
||||
private static final String PROCESSED_DIR = StringUtil.join(new String[] {
|
||||
"datadelivery", "harvester", "processed" }, File.separatorChar);
|
||||
|
@ -99,11 +101,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
|
|||
for (LocalizationFile file : files) {
|
||||
|
||||
try {
|
||||
|
||||
HarvesterConfig hc = SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(HarvesterConfig.class,
|
||||
file.getFile());
|
||||
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file.getFile());
|
||||
Agent agent = hc.getAgent();
|
||||
|
||||
if (agent != null) {
|
||||
|
@ -117,7 +115,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
|
|||
hcs.put(hc.getProvider().getName(), hc);
|
||||
}
|
||||
}
|
||||
} catch (SerializationException e1) {
|
||||
} catch (Exception e1) {
|
||||
statusHandler.error(
|
||||
"Serialization Error Reading Crawler Config files",
|
||||
e1);
|
||||
|
|
|
@ -12,13 +12,13 @@ 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.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
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.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -33,6 +33,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 4, 2012 1038 dhladky Initial creation
|
||||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -141,11 +142,10 @@ public abstract class CrawlLauncher implements Job {
|
|||
.getLocalizedFiles();
|
||||
|
||||
if (files != null) {
|
||||
JAXBManager jaxbMan = new JAXBManager(HarvesterConfig.class);
|
||||
for (LocalizationFile lf : files) {
|
||||
|
||||
HarvesterConfig hc = (HarvesterConfig) jaxbMan
|
||||
.unmarshalFromXmlFile(lf.getFile());
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
if (hc.getAgent() != null) {
|
||||
// we only want crawler types for CrawlerMetadata
|
||||
Agent agent = hc.getAgent();
|
||||
|
|
|
@ -16,9 +16,9 @@ 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.HarvesterJaxbManager;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Collection;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -38,6 +38,7 @@ import edu.uci.ics.crawler4j.crawler.CrawlConfig;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 4, 2012 1038 dhladky Initial creation
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -138,7 +139,7 @@ public abstract class Crawler {
|
|||
HarvesterConfig hc = null;
|
||||
|
||||
try {
|
||||
hc = SerializationUtil.jaxbUnmarshalFromXmlFile(
|
||||
hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(
|
||||
HarvesterConfig.class, configFile);
|
||||
} catch (SerializationException e1) {
|
||||
e1.printStackTrace();
|
||||
|
|
|
@ -34,6 +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.ProtoCollection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Collection;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
|
@ -73,6 +74,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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -373,7 +375,7 @@ class FileCommunicationStrategy implements CommunicationStrategy {
|
|||
File file = lf.getFile();
|
||||
|
||||
try {
|
||||
SerializationUtil.jaxbMarshalToXmlFile(hconfig,
|
||||
HarvesterJaxbManager.getJaxb().marshalToXmlFile(hconfig,
|
||||
file.getAbsolutePath());
|
||||
lf.save();
|
||||
} catch (SerializationException e) {
|
||||
|
|
|
@ -6,13 +6,13 @@ 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.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
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.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -29,6 +29,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController;
|
|||
* Mar 14, 2012 00357 dhladky Initial creation
|
||||
* Jun 12, 2012 00609 djohnson Update path to crawl script.
|
||||
* Aug 06, 2012 01022 djohnson Launch the crawler in the same JVM.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -78,8 +79,8 @@ public class MainSequenceCrawlLauncher extends CrawlLauncher {
|
|||
// if many, start many
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
HarvesterConfig hc = SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(HarvesterConfig.class,
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
if (hc.getProvider().getName().equals(providerName)) {
|
||||
if (hc.getAgent() != null) {
|
||||
|
|
|
@ -6,13 +6,13 @@ 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.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
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.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -28,6 +28,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 4, 2012 1038 dhladky Initial creation
|
||||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,8 +77,8 @@ public class SeedCrawlLauncher extends CrawlLauncher {
|
|||
// if many, start many
|
||||
for (LocalizationFile lf : getLocalizedFiles()) {
|
||||
|
||||
HarvesterConfig hc = (HarvesterConfig) new JAXBManager(
|
||||
HarvesterConfig.class).unmarshalFromXmlFile(
|
||||
HarvesterConfig hc = HarvesterJaxbManager.getJaxb()
|
||||
.unmarshalFromXmlFile(HarvesterConfig.class,
|
||||
lf.getFile());
|
||||
|
||||
if (hc.getProvider().getName().equals(providerName)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue