Skip to content

Commit

Permalink
change LidVidUtils.resolve() return type String -> PdsProductIdentifier
Browse files Browse the repository at this point in the history
also renames URIParameters member lidvid -> productIdentifier
  • Loading branch information
alexdunnjpl committed Jan 24, 2023
1 parent 992aa43 commit 3626b15
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected ResponseEntity<Object> processs (EndpointHandler handler, URIParameter
long begin = System.currentTimeMillis();
try
{
parameters.setAccept(this.request.getHeader("Accept")).setLidVid(this);
parameters.setAccept(this.request.getHeader("Accept")).setProductIdentifier(this);
if (parameters.getVerifyClassAndId()) LidVidUtils.verify (this, parameters);
return handler.transmute(this, parameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gov.nasa.pds.api.registry.exceptions.LidVidNotFoundException;
import gov.nasa.pds.api.registry.model.identifiers.LidVidUtils;
import gov.nasa.pds.api.registry.model.ProductVersionSelector;
import gov.nasa.pds.api.registry.model.identifiers.PdsProductIdentifier;
import gov.nasa.pds.api.registry.search.RequestBuildContextFactory;

/*
Expand Down Expand Up @@ -38,7 +39,7 @@ class URIParameters implements UserContext
private String group = "";
private String identifier = "";
private List<String> keywords = new ArrayList<String>();
private String lidvid = "";
private PdsProductIdentifier productIdentifier = null;
private Integer limit = Integer.valueOf(0);
private boolean summaryOnly = true;
private String query = "";
Expand All @@ -60,7 +61,7 @@ class URIParameters implements UserContext
@Override
public Integer getLimit() { return limit; }
@Override
public String getLidVid() { return lidvid; }
public String getLidVid() { return productIdentifier != null ? productIdentifier.toString() : ""; }
@Override
public String getQuery() { return query; }
@Override
Expand Down Expand Up @@ -119,9 +120,9 @@ public URIParameters setLimit(Integer limit)
}
return this;
}
public URIParameters setLidVid(ControlContext control) throws IOException, LidVidNotFoundException
public URIParameters setProductIdentifier(ControlContext control) throws IOException, LidVidNotFoundException
{
this.lidvid = LidVidUtils.resolve(this.getIdentifier(), ProductVersionSelector.SPECIFIC,
this.productIdentifier = LidVidUtils.resolve(this.getIdentifier(), ProductVersionSelector.SPECIFIC,
control, RequestBuildContextFactory.empty());
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gov.nasa.pds.api.registry.exceptions.MembershipException;
import gov.nasa.pds.api.registry.exceptions.UnknownGroupNameException;
import gov.nasa.pds.api.registry.model.identifiers.LidVidUtils;
import gov.nasa.pds.api.registry.model.identifiers.PdsProductIdentifier;
import gov.nasa.pds.api.registry.search.QuickSearch;
import gov.nasa.pds.api.registry.search.RequestBuildContextFactory;
import gov.nasa.pds.api.registry.util.GroupConstraintImpl;
Expand All @@ -30,10 +31,10 @@ private boolean isGrandchild (ReferencingLogicTransmuter idType)
private ReferencingLogicTransmuter resolveID (ControlContext context, UserContext input)
throws IOException, LidVidNotFoundException, UnknownGroupNameException
{
PdsProductIdentifier productIdentifier = LidVidUtils.resolve(input.getIdentifier(), ProductVersionSelector.SPECIFIC, context, RequestBuildContextFactory.empty());
return ReferencingLogicTransmuter.getByProductClass(
QuickSearch.getValue(context.getConnection(), input.getSelector() == ProductVersionSelector.LATEST,
LidVidUtils.resolve(input.getIdentifier(), ProductVersionSelector.SPECIFIC, context, RequestBuildContextFactory.empty()),
"product_class"));
productIdentifier != null ? productIdentifier.toString() : "", "product_class"));
}

private RequestAndResponseContext search(ControlContext context, UserContext input, boolean isIdToGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;

import gov.nasa.pds.api.registry.model.identifiers.LidVidUtils;
import gov.nasa.pds.api.registry.model.identifiers.PdsProductIdentifier;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.RestHighLevelClient;
Expand Down Expand Up @@ -112,11 +113,12 @@ private RequestAndResponseContext(
this.keywords = parameters.getKeywords();
this.fields = new ArrayList<String>();
this.fields.addAll(this.add_output_needs (parameters.getFields()));
this.lidvid = LidVidUtils.resolve(
parameters.getIdentifier(),
PdsProductIdentifier productIdentifier = LidVidUtils.resolve(
parameters.getIdentifier(),
versionSelectionScope,
controlContext,
RequestBuildContextFactory.given(parameters.getSelector() == ProductVersionSelector.LATEST, fields, resPreset));
controlContext,
RequestBuildContextFactory.given(parameters.getSelector() == ProductVersionSelector.LATEST, fields, resPreset));
this.lidvid = productIdentifier != null ? productIdentifier.toString() : "";
this.summaryOnly = parameters.isSummaryOnly();
this.limit = parameters.getLimit();
this.sort = parameters.getSort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static List<String> getAllLidVidsByLids(
return lidvids;
}

public static String resolve (
public static PdsProductIdentifier resolve (
String _identifier,
ProductVersionSelector scope,
ControlContext ctlContext,
Expand Down Expand Up @@ -136,7 +136,7 @@ public static String resolve (
}
}

return productIdentifier != null ? productIdentifier.toString() : "";
return productIdentifier;
}

public static void verify (ControlContext control, UserContext user)
Expand Down

0 comments on commit 3626b15

Please sign in to comment.