Skip to content

Commit

Permalink
return HTTP 501 not implemented for /api/v0/biomodel/<id>/biomodel.omex
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jul 19, 2024
1 parent 6fef158 commit 55ce3ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,39 @@ protected void describeGet(MethodInfo info) {
@Override
@Get(BiomodelOMEXResource.APPLICATION_OMEX_ZIP)
public ByteArrayRepresentation get_omex() {
VCellApiApplication application = ((VCellApiApplication)getApplication());
User vcellUser = application.getVCellUser(getChallengeResponse(),AuthenticationPolicy.ignoreInvalidCredentials);
boolean bSkipUnsupported = false;
StringBuffer suggestedProjectName = new StringBuffer();
ByteArrayRepresentation omexRep = getOmex(vcellUser, bSkipUnsupported, suggestedProjectName);

if (omexRep != null){
String bioModelID = (String)getRequestAttributes().get(VCellApiApplication.BIOMODELID);
// setAttribute("Content-type", "application/vcml+xml");
setAttribute("Content-Disposition", "attachment; filename=\""+suggestedProjectName+".omex\"");
return omexRep;
}
throw new RuntimeException("biomodel not found");
// TODO: Implement this method properly, as it is currently using too much resources
throw new ResourceException(Status.SERVER_ERROR_NOT_IMPLEMENTED, "biomodel.omex endpoint not implemented");
// VCellApiApplication application = ((VCellApiApplication)getApplication());
// User vcellUser = application.getVCellUser(getChallengeResponse(),AuthenticationPolicy.ignoreInvalidCredentials);
// boolean bSkipUnsupported = false;
// StringBuffer suggestedProjectName = new StringBuffer();
// ByteArrayRepresentation omexRep = getOmex(vcellUser, bSkipUnsupported, suggestedProjectName);
//
// if (omexRep != null){
// String bioModelID = (String)getRequestAttributes().get(VCellApiApplication.BIOMODELID);
//// setAttribute("Content-type", "application/vcml+xml");
// setAttribute("Content-Disposition", "attachment; filename=\""+suggestedProjectName+".omex\"");
// return omexRep;
// }
// throw new RuntimeException("biomodel not found");
}


private ByteArrayRepresentation getOmex(User vcellUser, boolean bSkipUnsupported, StringBuffer suggestedProjectName) {
RestDatabaseService restDatabaseService = ((VCellApiApplication)getApplication()).getRestDatabaseService();
try {
ByteArrayRepresentation omexRep = restDatabaseService.query(this, vcellUser, bSkipUnsupported, suggestedProjectName);
return omexRep;
} catch (PermissionException e) {
lg.error(e);
throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
} catch (ObjectNotFoundException e) {
lg.error(e);
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "biomodel not found");
} catch (Exception e){
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.toString());
}
}
// private ByteArrayRepresentation getOmex(User vcellUser, boolean bSkipUnsupported, StringBuffer suggestedProjectName) {
// RestDatabaseService restDatabaseService = ((VCellApiApplication)getApplication()).getRestDatabaseService();
// try {
// ByteArrayRepresentation omexRep = restDatabaseService.query(this, vcellUser, bSkipUnsupported, suggestedProjectName);
// return omexRep;
// } catch (PermissionException e) {
// lg.error(e);
// throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
// } catch (ObjectNotFoundException e) {
// lg.error(e);
// throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "biomodel not found");
// } catch (Exception e){
// throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.toString());
// }
// }


}
4 changes: 2 additions & 2 deletions vcell-api/src/main/resources/biomodel.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<#assign diagramlink="${pathPrefix}/biomodel/${biomodel.bmKey}/diagram">
<#assign vcmllink="${pathPrefix}/biomodel/${biomodel.bmKey}/biomodel.vcml">
<#assign sbmllink="${pathPrefix}/biomodel/${biomodel.bmKey}/biomodel.sbml">
<#assign omexlink="${pathPrefix}/biomodel/${biomodel.bmKey}/biomodel.omex">
<#--<#assign omexlink="${pathPrefix}/biomodel/${biomodel.bmKey}/biomodel.omex">-->
<#assign simstatuslink="${pathPrefix}/simstatus?submitLow=&submitHigh=&startRow=1&maxRows=10&hasData=all&active=on&running=on&completed=on&stopped=on&failed=on">
<#assign simtasklink="${pathPrefix}/simtask?submitLow=&submitHigh=&startRow=1&maxRows=10&hasData=all&waiting=on&queued=on&dispatched=on&running=on&completed=on&failed=on&stopped=on">
<center><h2><a href="${pathPrefix}/publication">Publications</a>&nbsp;&nbsp;&nbsp;<a href="${pathPrefix}/biomodel">BioModels</a>&nbsp;&nbsp;&nbsp;<a href="${simstatuslink}">Simulation Status</a>&nbsp;&nbsp;&nbsp;<a href="${simtasklink}">Simulation Tasks</a>&nbsp;&nbsp;&nbsp;<#if userid?? >(user: ${userid} <a href='${logouturl}'>Log out</a>)<#else>(not logged in <a href='${loginurl}'>sign in</a>)</#if></h2></center><br/><center>
Expand All @@ -17,7 +17,7 @@
<br>saved: ${biomodel.savedDate?number_to_date!""}</br>
<br><a href="${vcmllink}" type="application/vcml+xml" download="Biomodel_${biomodel.bmKey}.vcml">download vcml</a></br>
<br><a href="${sbmllink}" type="application/sbml+xml" download="Biomodel_${biomodel.bmKey}.sbml">download sbml</a></br>
<br><a href="${omexlink}" type="application/omex+zip" download="Biomodel_${biomodel.bmKey}.omex">download omex</a></br>
<#--<br><a href="${omexlink}" type="application/omex+zip" download="Biomodel_${biomodel.bmKey}.omex">download omex</a></br>-->
<br><img src="${diagramlink}" type="image/png"/></br>

<br/><h3>Applications</h3>
Expand Down
2 changes: 1 addition & 1 deletion vcell-rest/src/main/java/org/vcell/restq/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void main(String... args) {

public static final String VCML_DOWNLOAD = "biomodel.vcml";
public static final String SBML_DOWNLOAD = "biomodel.sbml";
public static final String OMEX_DOWNLOAD = "biomodel.omex";
// public static final String OMEX_DOWNLOAD = "biomodel.omex";
public static final String BNGL_DOWNLOAD = "biomodel.bngl";
public static final String DIAGRAM_DOWNLOAD = "diagram";
public static final String SIMULATION = "simulation";
Expand Down

0 comments on commit 55ce3ad

Please sign in to comment.