Search in sources :

Example 6 with PublicationRepresentation

use of org.vcell.rest.common.PublicationRepresentation in project vcell by virtualcell.

the class PublicationsServerResource method getPublicationRepresentations.

private PublicationRepresentation[] getPublicationRepresentations(User vcellUser) {
    ArrayList<PublicationRepresentation> publicationRepresentations = new ArrayList<PublicationRepresentation>();
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        PublicationRep[] publicationReps = restDatabaseService.query(this, vcellUser);
        for (PublicationRep publicationRep : publicationReps) {
            PublicationRepresentation publicationRepresentation = new PublicationRepresentation(publicationRep);
            publicationRepresentations.add(publicationRepresentation);
        }
    } catch (PermissionException ee) {
        ee.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized");
    } catch (DataAccessException | SQLException | ExpressionException e) {
        e.printStackTrace();
        throw new RuntimeException("failed to retrieve biomodels from VCell Database : " + e.getMessage());
    }
    return publicationRepresentations.toArray(new PublicationRepresentation[0]);
}
Also used : PermissionException(org.vcell.util.PermissionException) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ExpressionException(cbit.vcell.parser.ExpressionException) PublicationRepresentation(org.vcell.rest.common.PublicationRepresentation) PublicationRep(cbit.vcell.modeldb.PublicationRep) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) DataAccessException(org.vcell.util.DataAccessException)

Example 7 with PublicationRepresentation

use of org.vcell.rest.common.PublicationRepresentation in project vcell by virtualcell.

the class PublicationServerResource method getPublicationRepresentation.

private PublicationRepresentation getPublicationRepresentation(User vcellUser) {
    // if (!application.authenticate(getRequest(), getResponse())){
    // // not authenticated
    // return new SimulationTaskRepresentation[0];
    // }else{
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        PublicationRep publicationRep = restDatabaseService.query(this, vcellUser);
        PublicationRepresentation publicationRepresentation = new PublicationRepresentation(publicationRep);
        return publicationRepresentation;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "publication not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
// }
}
Also used : PermissionException(org.vcell.util.PermissionException) PublicationRepresentation(org.vcell.rest.common.PublicationRepresentation) PublicationRep(cbit.vcell.modeldb.PublicationRep) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Aggregations

PublicationRepresentation (org.vcell.rest.common.PublicationRepresentation)7 VCellApiApplication (org.vcell.rest.VCellApiApplication)6 PublicationRep (cbit.vcell.modeldb.PublicationRep)4 ResourceException (org.restlet.resource.ResourceException)4 PermissionException (org.vcell.util.PermissionException)4 User (org.vcell.util.document.User)4 Configuration (freemarker.template.Configuration)3 HashMap (java.util.HashMap)3 TemplateRepresentation (org.restlet.ext.freemarker.TemplateRepresentation)3 Representation (org.restlet.representation.Representation)3 ClientResource (org.restlet.resource.ClientResource)3 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)3 KeyValue (org.vcell.util.document.KeyValue)3 Gson (com.google.gson.Gson)2 StringRepresentation (org.restlet.representation.StringRepresentation)2 BiomodelReferenceRepresentation (org.vcell.rest.common.BiomodelReferenceRepresentation)2 MathmodelReferenceRepresentation (org.vcell.rest.common.MathmodelReferenceRepresentation)2 BioModelReferenceRep (cbit.vcell.modeldb.BioModelReferenceRep)1 MathModelReferenceRep (cbit.vcell.modeldb.MathModelReferenceRep)1 ExpressionException (cbit.vcell.parser.ExpressionException)1