Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Harvest to support multi-tenancy and OpenSearch Serverless #152

Merged
merged 17 commits into from
Jul 5, 2024
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>gov.nasa.pds</groupId>
<artifactId>registry-common</artifactId>
<version>1.5.1</version>
<version>1.6.0-SNAPSHOT</version>
</dependency>
<!-- rich XML parsing -->
<dependency>
Expand All @@ -128,8 +128,8 @@
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<!-- two artifacts for complete configuration parsing -->
<dependency>
<!-- three (3) artifacts for complete configuration parsing -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.1</version>
Expand Down
18 changes: 4 additions & 14 deletions src/main/java/gov/nasa/pds/harvest/cfg/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import org.glassfish.jaxb.runtime.v2.JAXBContextFactory;
import gov.nasa.pds.registry.common.cfg.RegistryCfg;
import gov.nasa.pds.registry.common.ConnectionFactory;
import gov.nasa.pds.registry.common.EstablishConnectionFactory;
import gov.nasa.pds.registry.common.meta.cfg.FileRefRule;

/**
Expand Down Expand Up @@ -41,19 +42,8 @@ static public List<String> exchangeLidvids (List<CollectionType> ids) {
}
return lidvids;
}
/**
* FIXME: This is a hack to keep changes limited to harvest.
* Replace the whole registry initiation with something different
* when moving to multitenancy
* @param xml2bean
* @return
*/
static public RegistryCfg exchangeRegistry (RegistryType xml) {
RegistryCfg bean = new RegistryCfg();
bean.authFile = xml.getAuth();
bean.indexName = xml.getIndex();
bean.url = xml.getServerUrl();
return bean;
static public ConnectionFactory exchangeRegistry (RegistryType xml) throws Exception {
return EstablishConnectionFactory.from (xml.getValue(), xml.getAuth());
}
static public HarvestConfigurationType read(File file) throws JAXBException {
JAXBContext jaxbContext = new JAXBContextFactory().createContext(new Class[]{Harvest.class}, null);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/gov/nasa/pds/harvest/cfg/Harvest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@


/**
*
* This terrible construct is so that xjc can autodetect this as the
* root node for processing. Many things would be better but this is
* the most workable solution especially if the making of the binding
* code is automated in the pom. The only other real solution is to
* modify one of the classes generated by hand.
*
*
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlSchemaType;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlType;

Expand All @@ -19,11 +19,11 @@
*
* These are the basic options for the harvest configuration file.
*
* @nodeName: the PDS node that this harvest run applies to
*
* autogenFields: should not be used except in development testing
* do: tells where and how to harvest PDS4 labels
* load: tells where and how to harvest PDS4 labels
* fileInfo: option allowing filename prefixes to be replaced
* nodeName: the PDS node that this harvest run applies to
* productFilter: should not be used except in development testing
* registry: define the server harvest should use
* xpathMaps: allow constraints in the PDS4 label to control harvesting
Expand All @@ -41,12 +41,12 @@
* <element name="autogenFields" type="{}autogen_fields_type" minOccurs="0"/>
* <element name="load" type="{}load_type"/>
* <element name="fileInfo" type="{}file_info_type" minOccurs="0"/>
* <element name="nodeName" type="{}node_name_enum"/>
* <element name="productFilter" type="{}filter_type" minOccurs="0"/>
* <element name="references" type="{}references_type" minOccurs="0"/>
* <element name="registry" type="{}registry_type"/>
* <element name="xpathMaps" type="{}xpath_maps_type" minOccurs="0"/>
* </all>
* <attribute name="nodeName" use="required" type="{}node_name_enum" />
* </restriction>
* </complexContent>
* </complexType>
Expand All @@ -67,13 +67,14 @@ public class HarvestConfigurationType {
@XmlElement(required = true)
protected LoadType load;
protected FileInfoType fileInfo;
@XmlElement(required = true)
@XmlSchemaType(name = "normalizedString")
protected NodeNameEnum nodeName;
protected FilterType productFilter;
protected ReferencesType references;
@XmlElement(required = true)
protected RegistryType registry;
protected XpathMapsType xpathMaps;
@XmlAttribute(name = "nodeName", required = true)
protected NodeNameEnum nodeName;

/**
* Gets the value of the autogenFields property.
Expand Down Expand Up @@ -147,6 +148,30 @@ public void setFileInfo(FileInfoType value) {
this.fileInfo = value;
}

/**
* Gets the value of the nodeName property.
*
* @return
* possible object is
* {@link NodeNameEnum }
*
*/
public NodeNameEnum getNodeName() {
return nodeName;
}

/**
* Sets the value of the nodeName property.
*
* @param value
* allowed object is
* {@link NodeNameEnum }
*
*/
public void setNodeName(NodeNameEnum value) {
this.nodeName = value;
}

/**
* Gets the value of the productFilter property.
*
Expand Down Expand Up @@ -243,28 +268,4 @@ public void setXpathMaps(XpathMapsType value) {
this.xpathMaps = value;
}

/**
* Gets the value of the nodeName property.
*
* @return
* possible object is
* {@link NodeNameEnum }
*
*/
public NodeNameEnum getNodeName() {
return nodeName;
}

/**
* Sets the value of the nodeName property.
*
* @param value
* allowed object is
* {@link NodeNameEnum }
*
*/
public void setNodeName(NodeNameEnum value) {
this.nodeName = value;
}

}
136 changes: 18 additions & 118 deletions src/main/java/gov/nasa/pds/harvest/cfg/RegistryType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,120 +10,76 @@
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlSchemaType;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlValue;
import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;


/**
*
* Define the connection to the registry, security for the connection, and
* the index within the registry.
* the index within the registry. The value of this tag is a pointer to
* a registry connection like app://known/direct/localhost.xml or
* app://known/cognito/first_test.xml
*
* @auth: a java property file containing a username and password
* @index: the index to be used by harvest whose default is registry
* @trust_self_signed: all self signed certificates for https
*
* cognito_client_id: the cognito client ID for AWS based instances of opensearch
* server_url: the opensearch URL when not using AWS services
*
*
*
* <p>Java class for registry_type complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>{@code
* <complexType name="registry_type">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <choice>
* <element name="cognito_client_id" type="{http://www.w3.org/2001/XMLSchema}normalizedString"/>
* <element name="server_url" type="{http://www.w3.org/2001/XMLSchema}normalizedString"/>
* </choice>
* <simpleContent>
* <extension base="<http://www.w3.org/2001/XMLSchema>normalizedString">
* <attribute name="auth" use="required" type="{http://www.w3.org/2001/XMLSchema}normalizedString" />
* <attribute name="index" type="{http://www.w3.org/2001/XMLSchema}normalizedString" default="registry" />
* <attribute name="trust_self_signed" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
* </restriction>
* </complexContent>
* </extension>
* </simpleContent>
* </complexType>
* }</pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "registry_type", propOrder = {
"cognitoClientId",
"serverUrl"
"value"
})
public class RegistryType {

@XmlElement(name = "cognito_client_id")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String cognitoClientId;
@XmlElement(name = "server_url")
@XmlValue
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String serverUrl;
protected String value;
@XmlAttribute(name = "auth", required = true)
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String auth;
@XmlAttribute(name = "index")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String index;
@XmlAttribute(name = "trust_self_signed")
protected Boolean trustSelfSigned;

/**
* Gets the value of the cognitoClientId property.
* Gets the value of the value property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCognitoClientId() {
return cognitoClientId;
public String getValue() {
return value;
}

/**
* Sets the value of the cognitoClientId property.
* Sets the value of the value property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCognitoClientId(String value) {
this.cognitoClientId = value;
}

/**
* Gets the value of the serverUrl property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getServerUrl() {
return serverUrl;
}

/**
* Sets the value of the serverUrl property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setServerUrl(String value) {
this.serverUrl = value;
public void setValue(String value) {
this.value = value;
}

/**
Expand All @@ -150,60 +106,4 @@ public void setAuth(String value) {
this.auth = value;
}

/**
* Gets the value of the index property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getIndex() {
if (index == null) {
return "registry";
} else {
return index;
}
}

/**
* Sets the value of the index property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setIndex(String value) {
this.index = value;
}

/**
* Gets the value of the trustSelfSigned property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isTrustSelfSigned() {
if (trustSelfSigned == null) {
return false;
} else {
return trustSelfSigned;
}
}

/**
* Sets the value of the trustSelfSigned property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setTrustSelfSigned(Boolean value) {
this.trustSelfSigned = value;
}

}
Loading
Loading