Skip to content

Commit

Permalink
changed to fit proposal
Browse files Browse the repository at this point in the history
Update swagger.yml to match the proposal plus any additions and clarification on the original ticket NASA-PDS/pds-api#202.

Re-arranged the code to fit the new API. Required some new exceptions and tweaks to the basic interfaces to support the membership concept outside of just referencing in general and that a lidvid necessarily match a particular product type.

Added new swagger transmutation layers to support the easy removal of deprecated code in the future and to support easier maintenance in the future. Left the old referencing suff only because there is a chance it may come back in the newish future to support some other use cases.

The new swagger transmutation layers still all funnel through a single processor once all of the inputs have been collected. The deprecated code mostly works itself through the new API showing that what could be done still can using the inew API. Did not want to update the standard handler to also check that desired class matches the lid(vid) so did not route those but they could also be done with a touch more code change just for that demonstration whcih is why it was not done.
  • Loading branch information
Al Niessner authored and Al Niessner committed Sep 1, 2022
1 parent bea5885 commit f526aa3
Show file tree
Hide file tree
Showing 16 changed files with 1,033 additions and 196 deletions.
212 changes: 204 additions & 8 deletions model/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,32 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/members/{versions}:
get:
tags:
- references
summary: |
returns one or more PDS Products that are members of the given PDS product class and lid/lidvid.
operationId: class-members-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Class"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/members/members:
get:
tags:
Expand All @@ -118,7 +143,32 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/members/members/{versions}:
get:
tags:
- references
summary: |
returns one or more PDS Products that are the members of the members of the given PDS product class and lid/lidvid.
operationId: class-members-members-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Class"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/member-of:
get:
tags:
Expand All @@ -144,7 +194,32 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/member-of/{versions}:
get:
tags:
- references
summary: |
returns one or more PDS Products that have the given PDS product class and lid/lidvid as a member.
operationId: class-member-of-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Class"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/member-of/member-of:
get:
tags:
Expand All @@ -170,7 +245,32 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/classes/{class}/{identifier}/member-of/member-of/{versions}:
get:
tags:
- references
summary: |
returns one or more PDS Products that have the given PDS product class and lid/lidvid as a member of its members.
operationId: class-member-of-of-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Class"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"

/products/{identifier}:
get:
Expand Down Expand Up @@ -264,7 +364,31 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/products/{identifier}/members/{versions}:
get:
tags:
- references
summary: |
returns all of the members of the given lid/lidvid
operationId: product-members-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/products/{identifier}/members/members:
get:
tags:
Expand All @@ -289,7 +413,31 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/products/{identifier}/members/members/{versions}:
get:
tags:
- references
summary: |
returns all of the members of the members of the given lid/lidvid
operationId: product-members-members-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/products/{identifier}/member-of:
get:
tags:
Expand All @@ -314,7 +462,31 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/products/{identifier}/member-of/{versions}:
get:
tags:
- references
summary: |
eturns one or more PDS Products that have the given PDS lid/lidvid as a member.
operationId: product-member-of-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"
/products/{identifier}/member-of/member-of:
get:
tags:
Expand All @@ -339,7 +511,31 @@ paths:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
#- $ref: "#/components/parameters/Versions"
/products/{identifier}/member-of/member-of/{versions}:
get:
tags:
- references
summary: |
returns one or more PDS Products that have the given PDS lid/lidvid as a member of its members.
operationId: product-member-of-of-vers
responses:
'200':
$ref: "#/components/responses/Plural"
'400':
$ref: "#/components/responses/Error"
'404':
$ref: "#/components/responses/Error"
'500':
$ref: "#/components/responses/Error"
'501':
$ref: "#/components/responses/Error"
parameters:
- $ref: "#/components/parameters/Fields"
- $ref: "#/components/parameters/Identifier"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Sort"
- $ref: "#/components/parameters/Start"
- $ref: "#/components/parameters/Versions"

# begin deprecated: this is the older API that is clutter
/bundles/{identifier}:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import gov.nasa.pds.api.registry.exceptions.ApplicationTypeException;
import gov.nasa.pds.api.registry.exceptions.LidVidNotFoundException;
import gov.nasa.pds.api.registry.exceptions.MembershipException;
import gov.nasa.pds.api.registry.exceptions.UnknownGroupNameException;
import gov.nasa.pds.api.registry.model.RequestAndResponseContext;

Expand All @@ -28,4 +29,16 @@ public RequestAndResponseContext find(ControlContext context, UserContext input)
*/
public RequestAndResponseContext given(ControlContext context, UserContext input)
throws ApplicationTypeException, IOException, LidVidNotFoundException, UnknownGroupNameException;

/**
* Find descendants as in children or grandchildren
*/
public RequestAndResponseContext member(ControlContext context, UserContext input, boolean twoSteps)
throws ApplicationTypeException, IOException, LidVidNotFoundException, MembershipException, UnknownGroupNameException;

/**
* Find heredity as in parents or grandparents
*/
public RequestAndResponseContext memberOf(ControlContext context, UserContext input, boolean twoSteps)
throws ApplicationTypeException, IOException, LidVidNotFoundException, MembershipException, UnknownGroupNameException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import gov.nasa.pds.api.registry.UserContext;
import gov.nasa.pds.api.registry.exceptions.ApplicationTypeException;
import gov.nasa.pds.api.registry.exceptions.LidVidNotFoundException;
import gov.nasa.pds.api.registry.exceptions.MembershipException;
import gov.nasa.pds.api.registry.exceptions.NothingFoundException;
import gov.nasa.pds.api.registry.exceptions.UnknownGroupNameException;

interface EndpointHandler
{
public ResponseEntity<Object> transmute (ControlContext control, UserContext content)
throws ApplicationTypeException,IOException,LidVidNotFoundException,NothingFoundException,UnknownGroupNameException;
throws ApplicationTypeException,IOException,LidVidNotFoundException,MembershipException,NothingFoundException,UnknownGroupNameException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gov.nasa.pds.api.registry.controller;

import java.io.IOException;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import gov.nasa.pds.api.registry.ControlContext;
import gov.nasa.pds.api.registry.ReferencingLogic;
import gov.nasa.pds.api.registry.UserContext;
import gov.nasa.pds.api.registry.exceptions.ApplicationTypeException;
import gov.nasa.pds.api.registry.exceptions.LidVidNotFoundException;
import gov.nasa.pds.api.registry.exceptions.MembershipException;
import gov.nasa.pds.api.registry.exceptions.NothingFoundException;
import gov.nasa.pds.api.registry.exceptions.UnknownGroupNameException;
import gov.nasa.pds.api.registry.model.ReferencingLogicTransmuter;
import gov.nasa.pds.api.registry.model.RequestAndResponseContext;

class Member implements EndpointHandler
{
final private boolean offspring, twoSteps;
public Member (boolean offspring, boolean twoSteps)
{
this.offspring = offspring;
this.twoSteps = twoSteps;
}

@Override
public ResponseEntity<Object> transmute(ControlContext control, UserContext content)
throws ApplicationTypeException, IOException, LidVidNotFoundException, MembershipException,
NothingFoundException, UnknownGroupNameException
{
ReferencingLogic transmuter = ReferencingLogicTransmuter.getBySwaggerGroup(content.getGroup()).impl();
RequestAndResponseContext context = this.offspring ? transmuter.member(control, content, this.twoSteps) :
transmuter.memberOf(control, content, this.twoSteps);
return new ResponseEntity<Object>(context.getResponse(), HttpStatus.OK);
}

}
Loading

0 comments on commit f526aa3

Please sign in to comment.